How to reset google oauth 2.0 authorization?

前端 未结 4 1085
无人及你
无人及你 2020-12-05 15:03

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 hav

相关标签:
4条回答
  • 2020-12-05 15:18

    Simply use: gapi.auth.setToken(null);

    0 讨论(0)
  • 2020-12-05 15:35

    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

    0 讨论(0)
  • 2020-12-05 15:37

    Its very simple. Just revoke the access.

    void RevokeAcess()
    {
        try{
        HttpClient client = new DefaultHttpClient();
        HttpPost post = new HttpPost("https://accounts.google.com/o/oauth2/revoke?token="+ACCESS_TOKEN);
        org.apache.http.HttpResponse response = client.execute(post);
        }
        catch(IOException e)
        {
        }
    }
    

    But it should be in asyncTask

    0 讨论(0)
  • 2020-12-05 15:38

    It depends what you mean by resetting authorization. I could think of a three ways of doing this:

    1. Remove authorization on the server
      Go to myaccount.google.com/permissions, find your app and remove it. The next time you try to sign in you have to complete full authorization flow with account chooser and consent screen.

    2. Sign out on the client
      gapi.auth2.getAuthInstance().signOut();
      In this way Google authorization server still remembers your app and the authorization token remains in browser storage.

    3. Sign out and disconnect
      gapi.auth2.getAuthInstance().signOut();
      gapi.auth2.getAuthInstance().disconnect();
      This is equivalent to (1) but on the client.

    0 讨论(0)
提交回复
热议问题