ssinganamalla
ssinganamalla

Reputation: 1280

chrome extension: getting user's email address who logs into the google account/gmail account

I have built a chrome extension. Using chrome.identity.getAuth(), I am able to get token as described here https://developer.chrome.com/apps/app_identity. This token seems to be for the user who is associated with the chrome.

I want to get a token or a user's email address who logs into the google account/gmail account. Is it possible to get this from within an extension?

Upvotes: 2

Views: 3335

Answers (1)

ssinganamalla
ssinganamalla

Reputation: 1280

I was able to solve this by choosing a web application type instead of a chrome app when generating the client id on google console.

  1. Choose a web application when you are generating the client key on google

    Javascript origins: https://<extensionid>.chromiumapp.org

    redirect url https://<extensionid>.chromiumapp.org/provider_cb

  2. extract the email page by reading the html from the contentscript.

  3. Pass a message with this email address to the background page.

  4. Follow the same as described in the github launchWebAuthFlow. [https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/github-auth]

  5. When calling the google auth url, also pass login_hint with the email address.

Upvotes: 1

Related Questions