Google+ Login: How to logout - using (gapi.auth.signOut)

微笑、不失礼 提交于 2019-12-03 12:47:53
frmi

If you want your user to be asked to reenter credentials, you will need to revoke the user's authentication to your application. In my application i did it like the snippet below. You might find this answer useful.

var token = gapi.auth.getToken();
if (token) {
  var accessToken = gapi.auth.getToken().access_token;
  if (accessToken) {
    // make http get request towards: 'https://accounts.google.com/o/oauth2/revoke?token=' + accessToken
    // In angular you can do it like this:
    // $http({
    //   method: 'GET',
    //   url: 'https://accounts.google.com/o/oauth2/revoke?token=' + accessToken
    // });
  }
}
gapi.auth.setToken(null);
gapi.auth.signOut();

The following command works perfectly for me.

gapi.auth2.getAuthInstance().disconnect();
Jakob Thuemoes

Using jquery, my buddy made this - and it works fine.

$('#signout').on('click', function(event) {
    gapi.auth.signOut();
});

To force account selection you can use 'prompt': 'select_account'

For me it's working well

    gapi.auth.authorize(
      {
        'client_id': YOURCLIENTID,
        'scope': SOMESCOPE,
        'authuser': -1,
        'prompt': 'select_account'
      },
      function (authResult) {
          .......
      }
    )
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!