【问题标题】:Invalid IDP response from Google Identity Toolkit来自 Google 身份工具包的 IDP 响应无效
【发布时间】:2015-01-06 11:45:49
【问题描述】:

我正在按照教程使用 Google Identity Toolkit 和 PHP 获得一个简单的应用程序 https://developers.google.com/identity-toolkit/quickstart/php

出现登录按钮,我可以选择我的 Google 帐户,我可以授予我的应用访问和阅读我的个人资料等权限。

然后我网站上的回调网址显示 'INVALID_IDP_RESPONSE' 和 Firebug 我看到了

https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyAssertion?key=mykeyremoved
Failed to load resource: the server responded with a status of 400 (Bad Request)

我已尝试重新运行本教程但没有成功,非常感谢任何有关如何推进此调试的帮助!

最好的问候 约翰

登录脚本按钮代码:www.exanple.com/index.php

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript" src="//www.gstatic.com/authtoolkit/js/gitkit.js"></script>
<link type="text/css" rel="stylesheet" href="//www.gstatic.com/authtoolkit/css/gitkit.css" />
<script type="text/javascript">
  var config = {
      apiKey: 'mykeyremoved',
      signInSuccessUrl: '/',
      idps: ["google"],
      oobActionUrl: '/',
      siteName: 'this site'
  };
  // The HTTP POST body should be escaped by the server to prevent XSS
  window.google.identitytoolkit.start(
      '#gitkitWidgetDiv', // accepts any CSS selector
      config,
      'JAVASCRIPT_ESCAPED_POST_BODY');
</script>


</head>
<body>
<!-- Placeholder for the sign in page -->
<div id="gitkitWidgetDiv"></div>
</body>
</html>

在 www.exanple.com/gitkit/index.php 的返回/重定向 url(这是产生错误代码的那个)

<!DOCTYPE html>
<html>
<head>
<?php
  set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ .'\quickapp\vendor\google\apiclient\src');
  require_once 
'quickapp/vendor/autoload.php';
  $gitkitClient=Gitkit_Client::createFromFile('http://www.exanple.com/quickapp/gitkit-server-config.json');
  $gitkitUser = $gitkitClient->getUserInRequest();
?>

<script type="text/javascript" src="//www.gstatic.com/authtoolkit/js/gitkit.js"></script>
<link type=text/css rel=stylesheet href="//www.gstatic.com/authtoolkit/css/gitkit.css" />
<script type=text/javascript>
  window.google.identitytoolkit.signInButton(
    '#navbar', // accepts any CSS selector
    {
      widgetUrl: "http://www.exanple.com/gitkit",
      signOutUrl: "/",
    }
  );
</script>

</head>
<body>

<div id="navbar"></div>
<p>
  <?php if ($gitkitUser) { ?>
    Welcome back!<br><br>
    Email: <?= $gitkitUser->getEmail() ?><br>
    Id: <?= $gitkitUser->getUserId() ?><br>
    Name: <?= $gitkitUser->getDisplayName() ?><br>
    Identity provider: <?= $gitkitUser->getProviderId() ?><br>
  <?php } else { ?>
    You are not logged in yet.
  <?php } ?>
</p>
</body>
</html>

【问题讨论】:

    标签: javascript php git


    【解决方案1】:

    你和我都有一个类似的错误,我们都收到了bad request from IDP 我目前正在向谷歌寻求帮助,无论如何,请随时查看下面的链接,该链接是关于我已问对的有关此事的问题现在我确实知道这可能不是您所期望的答案,但事实上,我正在尝试与您分享我所拥有的,一旦我能够确定地解决问题,我会尽快通知您。请随意查看以下链接

    Identity Toolkit does not work - Error code: Bad response from IDP

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-31
      • 2015-06-26
      相关资源
      最近更新 更多