如何持久访问用户的谷歌帐户?
我的应用程序从用户的 Google 日历中提取信息。 用户已经必须登录到我的应用程序,因此他们觉得很烦人,因为他们必须在每个会话中至少一次“授予访问权限”到他们的谷歌帐户(当前使用 OAuth)。
有没有办法获得永久(或更接近永久)的资助?
我什至愿意使用 openID 作为我的主要身份验证。那会有帮助吗?
我相信 GData API 提供了一个 ClientLogin 协议,该协议要求我存储用户的登录信息,我对此感到不舒服,但如果归根结底,我认为它比其他选择更好。
My app pulls info from my users' Google Calendars.
The users already have to login to my app, so they find it annoying that they have to "Grant Access" to their google account at least once per session (currently using OAuth).
Is there a way to get a permanent (or closer to it) grant?
I'm even open to using openID as my primary authentication. Would that help?
I believe the GData API offers a ClientLogin protocol which would require me to store the users' login info, and I'm not comfortable with that, although if it comes down to it I suppose it's better than the alternative.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
生成一次的 oAuth 令牌永远不会过期,除非用户/应用程序自己撤销它们。当用户第一次在您的应用程序上注册时,只需获取访问令牌和访问秘密令牌一次。将其存储在本地并在需要时使用它来查询 GDATA Api。
当用户再次登录时,您无需每次都请求访问令牌。
oAuth tokens generated once do not expire EVER unless user/application themselves revoke them. Just grab the access token and access secret token once for the first time when user registers on your app. Store it locally and use it to query the GDATA Api whenever you need.
You need not request the access tokens everytime when users log in again.
既然您使用的是 OAuth,我知道您的应用程序是一个 Web 应用程序?好吧,OAuth 是您遇到所描述问题的原因,这不完全是一个问题,而是 API 的一个功能。请注意,OAuth 连接经过数字签名,因此每次用户尝试登录时,他们都会被重定向到 OAuthAuthorizeToken 页面。
要解决您的问题,请使用 AuthSub 而不是 OAuth。它不太安全,但更方便。它还允许您的应用程序简单地接收一个令牌,表明用户已通过 Goodle 验证,因此您不需要以这种方式存储有关用户的任何信息。
希望这有帮助!
Since you are using OAuth I understand your application is a web-application? Well, OAuth is the reason you are having the problem you are describing, which is not exactly a problem but a feature of the API. See, OAuth connections are digitally signed therefore every time the user tries to login they are redirected to the OAuthAuthorizeToken page.
To solve your problems use AuthSub instead of OAuth. It is less secure but more convenient. Also it allows your application to simply receive a token saying that the user was verified by Goodle, therefore you wouldn't need to EVER store any information about your users this way.
Hope this helps!
有一个 Oauth/OpenID 混合解决方案(请参阅source) - 基本上你要求特定的范围访问权限,获取基本用户数据并请求令牌作为回报,然后将其交换为身份验证令牌并保存以供将来使用。
There is an Oauth/OpenID hybrid solution (see source) - basically you ask for certain scope access, get basic user data and request token in return, then you exchange it for auth token and save it for future use.