简体   繁体   中英

ASP.NET Identity External Login - How to get Google Token for API calls?

Just tried out the new ASP.NET Identity login system and added Google as external login provider.
Login works fine, but I can't find the authentication token for further API calls like

json = new WebClient().DownloadString(" https://www.googleapis.com/plus/v1/people/me?access_token= " + accessToken);

The only information I get back after a login is surname, givenname, email. Can someone show me where the token is hidden in the result?

Or do I need to set some optins in my Startup.Auth.cs where "app.UseGoogleAuthentication()" is set?

As far as I am aware the Google Authentication in ASP.NET Identity is OpenID based, so you will not be able to make calls to the Google+ API which requires an OAuth access token. In order to do that you (or someone else) will need to develop a Google+ authentication provider for ASP.NET Identity which is based on OAuth.

For OAuth based providers such as Twitter and Facebook you can use the mechanism I described in a blog post at http://www.beabigrockstar.com/get-the-twitter-profile-image-using-the-asp-net-identity/ to retrieve and store the access token and then use that in subsequent calls.

Update : I have developed an OAuth provider for Google+ with an example of how to store the token and use it to make OAuth calls. For more details see blog post at http://www.beabigrockstar.com/google-oauth-sign-asp-net-identity/

您可能会执行类似于以下关于如何存储Facebook访问令牌的问题的操作: 如何存储/检索Facebook访问令牌

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