相关疑难解决方法(0)

gapi.auth.signOut()在没有实现更改的情况下停止工作

我使用Google Plus作为登录,直到最近才运行良好.现在用户无法再退出.回调工作并返回用户已注销的内容,但之后会立即再次签署用户.好像它没有存储注销.

有一些老问题就像这个问题.我尝试了所有提议的解决方案但没有任何效果

html头中的代码

<script src="https://apis.google.com/js/client:platform.js?onload=start" async defer></script>
Run Code Online (Sandbox Code Playgroud)

按钮代码,始终显示(登录时隐藏)

<div id="signinButton">
  <span class="g-signin"
    data-scope="https://www.googleapis.com/auth/gmail.readonly"
    data-clientid="{{ CLIENT_ID }}"
    data-redirecturi="postmessage"
    data-accesstype="offline"
    data-cookiepolicy="single_host_origin"
    data-callback="signInCallback">
  </span>
</div>
Run Code Online (Sandbox Code Playgroud)

SignIn和SignOut函数

<script>
  function signInCallback(authResult) {
    //console.log(authResult)
    if (authResult['code']) {

      var state = encodeURIComponent('{{ STATE }}');
      var code = encodeURIComponent(authResult['code']);          
      var tz = encodeURIComponent($('#timezone').val());
      var cntry = encodeURIComponent($('#country').val());
      var lan = encodeURIComponent('{{ language }}');

      // Send the code to the server
      $.ajax({
        type: 'POST',
        url: '/signup/gauth',
        contentType: 'application/octet-stream; charset=utf-8',
        success: function(result) {
          console.log(result)
          if (result == …
Run Code Online (Sandbox Code Playgroud)

google-api google-plus google-signin

10
推荐指数
1
解决办法
3359
查看次数

Google+登录:如何退出 - 使用(gapi.auth.signOut)

我需要一些关于如何使用您的Google+帐户登录的网站创建退出功能的帮助.

文档说明您应该使用gapi.auth.signOut函数

https://developers.google.com/+/web/signin/sign-out

但作为javascript的新手我似乎没有任何运气.

这是我的代码 - 注销功能是底部的部分.我究竟做错了什么?

<script>


function signinCallback(authResult) {
  if (authResult['status']['signed_in']) {
    // Update the app to reflect a signed in user
    // Hide the sign-in button now that the user is authorized, for example:
          document.getElementById('signinButton').setAttribute('style','display: none ');
          document.getElementById('callback').setAttribute('style','height: 100px;background-color: red ');

        var mydiv = document.getElementById("callback");
        var aTag = document.createElement('a');
        aTag.innerHTML = "Sign out";
        aTag.id= "signout";
        mydiv.appendChild(aTag);


/*function checkid(){
    document.getElementById('signout')
    }*/

} else {
    // Update the app to reflect a signed out user
    // Possible error values: …
Run Code Online (Sandbox Code Playgroud)

logout google-plus

8
推荐指数
3
解决办法
2万
查看次数

Google API注销已停止工作

类似的问题已经被问到,问题是gapi.auth.signout()在localhost中不起作用:gapi.auth.signOut(); 不工作我迷路了

但它在一个真实的网站上运行良好,直到突然,我的结果没有变化.它现在不会签署用户,所以如果他们退出我的网站,他们的Google身份验证仍然有效.下面是一些示例代码,我认为应该不是说用户仍然签署了:

 gapi.auth.authorize({ 'client_id': CLIENT_ID, 'scope': SCOPES, 'immediate': false, cookie_policy: 'single_host_origin'}, function (authResult) {
    gapi.auth.signOut();
    setTimeout(function() {
        gapi.auth.authorize({ 'client_id': CLIENT_ID, 'scope': SCOPES, 'immediate': true, cookie_policy: 'single_host_origin'}, function (authResult) {
            if (authResult && !authResult.error)
                alert("Still signed in");
        })
    }, 5000);
 });
Run Code Online (Sandbox Code Playgroud)

这似乎是完全错误和不安全的.我过去测试了我的原始代码并且它运行正常,所以我认为最近Google API可能会出现回归.

oauth google-api oauth-2.0 google-plus google-oauth

7
推荐指数
0
解决办法
739
查看次数

如何使用Google+登录时注销

谷歌在那里记录gapi.auth.signOut()方法:https://developers.google.com/+/web/signin/#sign-out

问题在于它说你只能在signinCallback触发后调用该方法.据我所知,解雇的唯一方法signinCallback是在页面上放置一个登录按钮.

这在我的登录页面本身很有效,但是一旦我对用户进行了身份验证,就不需要在后续页面上放置G +登录按钮.我只想在角落里有一个小的"注销"链接,用户可以点击该链接进行注销.

我尝试使用我的注销链接调用,gapi.auth.signOut()但除非我还显示一个无用的登录按钮,否则它什么都不做.我如何让它工作?

oauth-2.0 google-plus

6
推荐指数
1
解决办法
4912
查看次数