Require Google to return email address as part of OAuth

后端 未结 7 716
情歌与酒
情歌与酒 2020-12-23 10:23

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

7条回答
  •  一个人的身影
    2020-12-23 10:30

    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

提交回复
热议问题