简体   繁体   中英

Fetching User Info like Name, Email using Google OAuth2

I am using Google's .NET SDK in my application and would like to get the user info. I have obtained the UserCredential object using the below scopes.

  new[] { Uri.EscapeUriString("https://www.googleapis.com/auth/userinfo.email"), 
          Uri.EscapeUriString("https://www.googleapis.com/auth/userinfo.profile") }

After this am looking for a UserInfoService to fetch the name and email of the user but it is not to be found. Note I am only using Google's SDK and not handling the request and response myself.
I have found few samples in other sites but those don't use the Google API and are forming the
request url and need to parse the response JSON.

Is there a way I can get the UserInfo without myself creating the request url and leave this to be handled by the Google API ?

That was already asked before here: .NET client for the Google People API

Anyway, you should use the OAuth 2.0 library, and it looks like you will be interested in the UserInfoResource.GetRequest .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM