Gmail OAuth用于获取用户详细信息

编程入门 行业动态 更新时间:2024-10-22 11:01:50
本文介绍了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... 完成此步骤后,用户将被重定向回您的网站(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用于获取用户详细信息

本文发布于:2023-11-17 08:24:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609456.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:详细信息   用户   Gmail   OAuth

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!