Skip to content

Instantly share code, notes, and snippets.

@bluejack
Last active June 22, 2022 20:57
Show Gist options
  • Save bluejack/136b0a99d89588718018bdf9fee92fcf to your computer and use it in GitHub Desktop.
Save bluejack/136b0a99d89588718018bdf9fee92fcf to your computer and use it in GitHub Desktop.
function authorize_api_usage(client_id, scope, user) {
return new Promise((res,rej) => {
const token_client = google.accounts.oauth2.initTokenClient({
client_id,
scope,
hint: user.email,
callback: (response) => {
if (!response.access_token) {
return rej('authorization-failed');
}
res();
}
});
token_client.requestAccessToken({prompt: ''});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment