尝试谷歌加登录我的网络应用程序时,继续获得"超出未经验证的使用的每日限制.持续使用需要注册"

Mic*_*ana 48 javascript php google-api google-plus

我正在尝试在我的网络应用上实施Google plus注册,然后我按照谷歌文档设置注册但是当我在接受权限后尝试注册并使用访问令牌返回给我任何api restcall我返回超出未经身份验证的使用的每日限制.继续使用需要注册错误.我已经使用ouath 2.0密钥注册了我的应用程序,所以我似乎没有得到我做错了什么.这是我的代码.

方方:

const clientId = "5XXX000XX.apps.googleusercontent.com";
const apiKey = "AIzaSyCAXE5JSa36jcC*X7HV40SBcIWBiVGUTBE";
const scopes = "https://www.googleapis.com/auth/plus.login";
let accessToken = null;

function initer() {
  gapi.client.setApiKey(apiKey);
  // alert("Hello init");
  if ($("#authorize-button").length > 0) {
    $("#authorize-button").click(onLoginClick);
  }
}

function onLoginClick() {
  // $("#modalLoading").modal();
  // alert("yeah");
  gapi.auth.authorize({ client_id: clientId, scope: scopes, immediate: false }, onConnect);
}

function onConnect(authResult) {
  // alert("On connect");
  if (authResult && !authResult.error) {
    alert("Hey");
    accessToken = authResult.access_token;
    triggerLogin();
  } else {
    alert("Error");
  }
}

triggerLogin = function() {
  alert("Triggering login");
  $("#modalLoading").modal();
  $.ajax({
    url: window.config.site_root + "account/google_login",
    type: "POST",
    data: "access_token=" + accessToken,
    success: onLogin,
    error() {
      onError("Logging In", "starting your session");
    },
  });
};

onLogin = function(login) {
  alert("Login start");
  $("#modalLoading").modal("hide");
  if (login.operation) {
    location.reload();
  } else {
    alert("Register will start");
    triggerRegistration();
  }
};

triggerRegistration = function() {
  $("#modalLoading").modal();
  $.ajax({
    url: window.config.site_root + "account/google_registration",
    type: "POST",
    data: "access_token=" + accessToken,
    success: onRegistration,
    error() {
      alert("An Error");
    },
  });
};

onRegistration = function(data) {
  alert("Handling register");
  $("#modalLoading").modal("hide");
  if (data.account_exists) {
    stage.showErrorModal(
      "Account already registered",
      "There is already an account with that email address, are you sure you created an account using this login method?",
    );
  } else if (data.operation) {
    alert("Login now");
    triggerLogin();
  } else {
    alert("Error");
    onError("Registering", "creating your account");
  }
};
Run Code Online (Sandbox Code Playgroud)

这是我的服务器端代码

 public function google_registration()
            {
                $access_token = (isset($_POST["access_token"]) && !empty($_POST["access_token"])) ? $_POST["access_token"] : null;


                $name = null;
                $email = null;
                $account_id = null;
                $picture = null;
                $gender = null;

                try
                {
                    if($access_token)
                    {
                        $me = file_get_contents("https://www.googleapis.com/plus/v1/people/me?access_token=".$access_token);
                        if($me)
                        {
                            $me = json_decode($me);
                            $name = $me->name.formatted;
                            $email = $me->email;
                            $account_id = $me->id;
                            $picture = $me->image;
                            $gender = ($me->gender == "female") ? 1 : 0;
                        }
                    }
                }
                catch(Exception $error)
                {
                    // let the system handle the error quietly.
                }
                return $this->service_registration("google", $name, $email, $account_id, $picture, $gender);

            }
Run Code Online (Sandbox Code Playgroud)

use*_*439 30

我也遇到了同样的错误 - "超出未经验证的使用的每日限制.持续使用需要注册".

我在API下检查了我的谷歌开发者控制台,用于与API密钥/身份验证密钥相关联的项目,例如https://console.developers.google.com/project/<your app id>/apiui/api.Google + API的状态设置为OFF.我把它打开了.

然后我获得了另一个访问令牌,然后尝试使用新的令牌.它工作,即错误消失了,我得到了配置文件的详细信息.要反复核对这是否确实是导致错误的原因,我又回到了控制台并停用了Google+ API.但现在,我得到错误:

"未配置访问权限.请使用Google Developers Console激活项目的API."

因此,我并非100%确定这是在我的开发者控制台中启用/关闭Google+ API,但请确保已启用此功能.此外,请在开机后等待几分钟,并确保每次尝试前都获得一个新的令牌.


Man*_*s D 11

谷歌api

确保您已启用Google+ Api.

没有它你会得到如下错误:

"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
Run Code Online (Sandbox Code Playgroud)

要启用它:

1)打开https://console.developers.google.com

2)选择你的项目(右上角)

3)在搜索框中搜索"Google+ API",如果尚未启用,则启用它.

  • 好.我找到了.但限制设定为10 000,我只测试......低于20次.所以它不能解决我的问题.谢谢 (3认同)
  • 这似乎又过时了 (3认同)

www*_*.me 10

当您已登录并仍尝试一次又一次登录时,会发生此问题.我遇到了同样的错误所以做了一些实验1)我在手机上打开网站,一切都很好.2)然后我尝试了另一台笔记本电脑,并使用不同的Gmail帐户登录,它再次工作正常.3)在我的第一台笔记本电脑上我通过点击"登录"按钮再次绑定我得到了相同的错误,所以我打开了google.com然后完全退出然后再次尝试,这次它有效.所以我相信,问题是一次又一次地点击登录按钮而不注销.

我不确定这是否真的是一个问题,但至少这是我发现的.我仍在尝试,尝试和尝试,如果我找到了其他任何东西,我会发布.

干杯!!

  • 这绝对也是我的问题。非常令人困惑,因为 API 都已启用,我正确地传递了所有内容,但该错误消息太可怕了!我打开了一个隐身窗口,它立即起作用了。在普通浏览器中注销,然后再次登录,它再次完美运行。谢谢! (2认同)

小智 9

你必须添加apiKeyURL:

$curl = curl_init( 'https://www.googleapis.com/urlshortener/v1/url?key=AIza3834-Key' );
Run Code Online (Sandbox Code Playgroud)


sup*_*san 8

所以我遇到了这个问题,上面两个方法/解决方案(启用API访问和退出帐户)对我来说不起作用,因为对于google + signin,你必须在http调用的授权头中传入访问令牌.

以下是通过jQuery实现的方法:

    $.ajax({
      type: "GET", 
      url: "https://www.googleapis.com/plus/v1/people/me",
      headers: {
       "Authorization":"Bearer " + {access_token},
      }
    });
Run Code Online (Sandbox Code Playgroud)

看来你的问题在于服务器端代码,你在params中传入access_token(这是不必要的).

这是我对PHP实现的看法:

$opts = array(
'http'=>array(
 'method'=>"GET",
 'header'=>"Authorization: Bearer ".$access_token 
 )
);

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file = file_get_contents('https://www.googleapis.com/plus/v1/people/me', false, $context);'
Run Code Online (Sandbox Code Playgroud)

  • 尽管官方文档确实声明您可以将 access_token 作为查询参数或在标头中传递,但在查询中传递它时我总是收到该错误。它仅在作为标头传递时才有效。它说:“通过包含 access_token 查询参数或 Authorization: Bearer HTTP 标头,将访问令牌包含在对 API 的请求中”。这是链接:https://developers.google.com/identity/protocols/OAuth2WebServer (2认同)

Ian*_*ber 5

希望你通过https发送访问令牌!可能值得考虑使用代码并在服务器端进行交换以获取访问令牌,以提高安全性,如果没有别的话,这里有一些关于该方法的文档:https://developers.google.com/+/web /登入/服务器端流

关于你所看到的问题,似乎访问令牌是坏的,或者没有正确地通过它.您是否可以检查您在tokeninfo终端上收到的访问令牌:https://www.googleapis.com/oauth2/v1/tokeninfo? access_token = - 应显示有效信息.在代码中没有任何突出显示,但如果令牌被破坏,您可能会看到类似的错误.