Search code examples
google-plusgoogle-oauthgoogle-apps-marketplacegoogle-signingoogle-oauth-java-client

Google get email proper scopes


A lot of the documentation on google talks about the email scope to replace the https://www.googleapis.com/auth/userinfo.email, pared with the endpoint https://www.googleapis.com/userinfo/v2/me. Documentation found here https://developers.google.com/+/api/oauth#email.

Yet there is more documentation that states even that is being replaced in favor of the plus api and endpoint and the people.get endpoint. Documentation found here https://developers.google.com/+/api/auth-migration#email.

I have an application that needs to request the user email for both authentication and to verify they have installed our app.. A bonus is when I try to add the email scope to the developer console, or use it in my app, it tells me that email is not a valid scope.
My question is what are the proper scopes that need be applied in my app and in the google developer console? Need to be sure of this since the Google Apps Marketplace V2 has rules about prompting users.


Solution

  • You need to use the "email+profile" scope. That's the only way you will comply with the marketplace requirements to hide the user consent window.

    Don't worry about the API console saying this is not a valid scope, it works when you provide it to the OAuth endpoint.

    Here's an explanatory blog post with a sample in Java and all the required configuration steps.