Google-api-nodejs-client: Multiple Google Accounts without logout

Created on 17 Dec 2017  路  1Comment  路  Source: googleapis/google-api-nodejs-client

Hi there,
after the user has added the first google account, a repeated generateAuthUrl does no longer ask for new credentials. I have clients who have multiple google accounts and would like to integrate all of them, how do I fix/work around this limitation?

Most helpful comment

Greetings! You want to set prompt: 'select_account' in the options for generateAuthUrl. You can read about this option here:
https://developers.google.com/identity/protocols/OAuth2WebServer#creatingclient

And you can see a full OAuth2 example here:
https://github.com/google/google-auth-library-nodejs/blob/master/examples/oauth2.js

And you need to do something like this:

const authorizeUrl = oAuth2Client.generateAuthUrl({
  access_type: 'offline',
  scope: 'https://www.googleapis.com/auth/plus.me',
  prompt: 'select_account'
});

Hope this helps!

>All comments

Greetings! You want to set prompt: 'select_account' in the options for generateAuthUrl. You can read about this option here:
https://developers.google.com/identity/protocols/OAuth2WebServer#creatingclient

And you can see a full OAuth2 example here:
https://github.com/google/google-auth-library-nodejs/blob/master/examples/oauth2.js

And you need to do something like this:

const authorizeUrl = oAuth2Client.generateAuthUrl({
  access_type: 'offline',
  scope: 'https://www.googleapis.com/auth/plus.me',
  prompt: 'select_account'
});

Hope this helps!

Was this page helpful?
0 / 5 - 0 ratings