Require Google to return email address as part of OAuth

Khash picture Khash · Jun 27, 2010 · Viewed 23.6k times · Source

I am using OAuth to access Gmail with dotNetOAuth. How can I force Google to return user's email address as part of callback after authorization?

By default, Google OAuth callback only returns the token secret and access tokens.

Answer

mergoc picture mergoc · Nov 24, 2010

First you need to add the following scope (https://www.googleapis.com/auth/userinfo.email) to your oauth request.

After you're back to your app from Google and you have your access token, you can make a request using the access token to https://www.googleapis.com/userinfo/email?alt=json. This will return the email address. More info at http://sites.google.com/site/oauthgoog/Home/emaildisplayscope