Search code examples
google-apioauth-2.0google-oauthgoogle-api-client

How to reset google oauth 2.0 authorization?


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.


Solution

  • 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