如何重置 google oauth 2.0 授权? [英] How to reset google oauth 2.0 authorization?
问题描述
我正在使用 适用于 JavaScript 的 Google API 客户端库(测试版)在 Web 应用程序上授权用户 google 帐户(用于 youtube 操作).一切正常,但我不知道如何从我的应用程序注销"用户,即重置访问令牌.
例如,以下代码检查用户授权,如果没有,则显示弹出窗口供用户登录帐户并允许网络应用程序访问用户数据:
gapi.auth.authorize({client_id: CLIENT_ID, scope: SCOPES,immediate: false}, handleAuth);
但是客户端库没有重置授权的方法.
有解决方法将用户重定向到accounts.google.com/logout",但这方法不是我需要的:因此,我们不仅从我的应用程序,而且在任何地方都将用户从谷歌帐户注销.
Google 常见问题解答和客户端库说明都没有帮助.
尝试撤销访问令牌,这应该会撤销实际授权,因此自动批准将停止工作.我想这会解决您的问题.
https://developers.google.com/accounts/docs/OAuth2WebServer#tokenrevoke>
I'm using Google APIs Client Library for JavaScript (Beta) to authorize user google account on web application (for youtube manipulations). Everything works fine, but i have no idea how to "logout" user from my application, i.e. reset access tokens.
For example, following code checks user authorization and if not, shows popup window for user to log into account and permit web-application access to user data:
gapi.auth.authorize({client_id: CLIENT_ID, scope: SCOPES, immediate: false}, handleAuth);
But client library doesn't have methods to reset authorization.
There is workaround to redirect user to "accounts.google.com/logout", but this approach is not that i need: thus we logging user off from google account not only from my application, but also anywhere.
Google faq and client library description neither helpful.
Try revoking an access token, that should revoke the actual grant so auto-approvals will stop working. I assume this will solve your issue.
https://developers.google.com/accounts/docs/OAuth2WebServer#tokenrevoke
这篇关于如何重置 google oauth 2.0 授权?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!