Gmail OAuth用于获取用户详细信息 [英] Gmail OAuth For get users Details

查看:84
本文介绍了Gmail OAuth用于获取用户详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用OAuth从gmail获取用户个人资料详细信息,使用 DotNetOpenAuth.dll 进行 OAuth 身份验证来自gmail,它点击google登录进行身份验证并正确地重定向到我的网站,但我不知道如何捕获该访问令牌



如需参考,这里是链接



OAuth 2.0与Gmail over IMAP for web applications [ ^ ]。



如果有人有其他想法,请帮助我在等。

如果有人为此提供样品会更有帮助。



谢谢

I need to get user profile details from gmail using OAuth for that am using DotNetOpenAuth.dll for OAuth authentication from gmail , its hitting the google login for authentication and redirect to my site correctly but I don''t know how to catch that access token.

For Reference here is the link

OAuth 2.0 with Gmail over IMAP for web applications[^].

If anybody having some other ideas please help me am waiting.
If anybody having sample for that it will more helpful.

Thank you

推荐答案

如果你浏览了你提供的链接,解决方案就在那里。

如下所示...

If you go through the link you have provided, the solution is there itself.
It says like below...


完成此步骤后,用户将被重定向回您的网站(http://www.yourdomain.com/oauth2callback)。以下是此回调代码。其目的是获取刷新令牌和访问令牌:


After this step user is redirected back to your website (http://www.yourdomain.com/oauth2callback). Following is this callback code. Its purpose is to get a refresh-token and an access-token:
WebServerClient consumer= new WebServerClient(server, clientID, clientSecret);
consumer.ClientCredentialApplicator =
    ClientCredentialApplicator.PostParameter(clientSecret);
IAuthorizationState grantedAccess = consumer.ProcessUserAuthorization(null);

string accessToken = grantedAccess.AccessToken;



访问令牌通常有效最多一个小时,并允许您访问用户的数据。您还收到了刷新令牌。刷新令牌可用于在先前过期后请求新的访问令牌。


An access token is usually valid for a maximum of one hour, and allows you to access the user’s data. You also received a refresh token. A refresh token can be used to request a new access token once the previous expired.

示例项目链接 -

参考dotnetopenid / samples / OAuthConsumer / GoogleAddressBook.aspx.cs [ ^ ]和dotnetopenid / samples / OAuthConsumer [ ^ ]完整项目。

谢谢......

Sample Project links -
Refer dotnetopenid / samples / OAuthConsumer / GoogleAddressBook.aspx.cs[^] for sample page and dotnetopenid / samples / OAuthConsumer[^] for full project.
Thanks...


这篇关于Gmail OAuth用于获取用户详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆