1
votes

I am using Flask dance in order to authenticate users (using Google as auth provider) I try to get the user email and tried few options - non of them returned the email.

Code snippet:(google is flak-dance Google blue print)

   if not google.authorized:
            return redirect(url_for("google.login"))
   else:
       resp = google.get(url)

I have tried the following urls:

  1. https://openidconnect.googleapis.com/v1/userinfo

  2. https://www.googleapis.com/auth/userinfo.email

  3. https://www.googleapis.com/oauth2/v3/userinfo

  4. https://www.googleapis.com/oauth2/v3/tokeninfo

I was using the scope: scope=["profile", "email"] when the Google blueprint was created. The data structure that I get as result is:

{'sub': 'XYZ', 'name': 'XYZ', 'given_name': 'XYZ',
 'family_name': 'XYZ', 'picture': 'XYZ', 'locale': 'XYZ'}

On page https://console.cloud.google.com/apis/credentials/consent, Under the 'OAuth consent screen' page, under the section 'Scopes for Google APIs' I have the following entries:

  • email
  • profile
  • openid

My question is:

How do I get the the fields above and the user's email?

Thanks

1

1 Answers

1
votes