我需要使用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... 完成此步骤后,用户将被重定向回您的网站(www.yourdomain/oauth2callback)。以下是此回调代码。其目的是获取刷新令牌和访问令牌: After this step user is redirected back to your website (www.yourdomain/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用于获取用户详细信息
发布评论