0

I'm followin the tutorial to get a simple app with Google Identity Toolkit and PHP https://developers.google.com/identity-toolkit/quickstart/php

The login button appears, I can select my Google account, I can grant my app permission to access and read my profile etc.

The callback url on my site then says 'INVALID_IDP_RESPONSE' and in Firebug I see

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

I have tried rerunning the tutorial without success, any help on how to take this debugging forward would be greatly appreciated!

Best regards Johan

Login script button code: 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>

Return/redirect url at www.exanple.com/gitkit/index.php (which is the one producing the error code)

<!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>

1 Answers1

0

you and me have a similar error both of us receive a bad request from IDP I am currently asking help to google and at any rate feel free to look at the below link that is about a question concerning this matter that I have asked right now I do know this might not be the answer you'd have expected but as a matter of fact I am trying to share with you what I have and I will let you know as soon as I am able to definitely solve the problem. Please feel free to look at the below link

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

Community
  • 1
  • 1