Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenID Implementation for Google.. 400 Bad Request
    text
    copied!<p>So I'm trying to get a grasp of OpenID, and I feel I understand the theory, etc... now it's come to implementing it. I've got a very basic setup that sends a curl request to the google provider address..</p> <pre><code>https://www.google.com/accounts/o8/id </code></pre> <p>parses the returned XRDS xml file</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)"&gt; &lt;XRD&gt; &lt;Service priority="0"&gt; &lt;Type&gt;http://specs.openid.net/auth/2.0/server&lt;/Type&gt; &lt;Type&gt;http://openid.net/srv/ax/1.0&lt;/Type&gt; &lt;Type&gt;http://specs.openid.net/extensions/ui/1.0/mode/popup&lt;/Type&gt; &lt;Type&gt;http://specs.openid.net/extensions/ui/1.0/icon&lt;/Type&gt; &lt;Type&gt;http://specs.openid.net/extensions/pape/1.0&lt;/Type&gt; &lt;URI&gt;https://www.google.com/accounts/o8/ud&lt;/URI&gt; &lt;/Service&gt; &lt;/XRD&gt; &lt;/xrds:XRDS&gt; </code></pre> <p>After retrieving the actual provider for google from their XRDS document I redirect using this function...</p> <pre><code>public function RedirectToEndpoint() { $params = array(); $params['openid.mode'] = 'checkid_setup'; $params['openid.ns'] = 'http://specs.openid.net/auth/2.0'; $params['openid.claimed_id'] = 'http://specs.openid.net/auth/2.0/identifier_select'; $params['openid.identity'] = 'http://specs.openid.net/auth/2.0/identifier_select'; $params['openid.return_to'] = $this-&gt;URLs['return_to']; $params['openid.realm'] = $this-&gt;URLs['realm']; $join = stripos($this-&gt;URLs['openid_server'], '?') ? '&amp;' : '?'; $redirect_to = $this-&gt;URLs['openid_server'] . $join . $this-&gt;array2url($params); if (headers_sent()){ // Use JavaScript to redirect if content has been previously sent (not recommended, but safe) echo '&lt;script language="JavaScript" type="text/javascript"&gt;window.location=\''; echo $redirect_to; echo '\';&lt;/script&gt;'; }else{ // Default Header Redirect header('Location: ' . $redirect_to); } } </code></pre> <p>The array2url is a simple function which converts the assoc array $params to append to the query string.</p> <p>The generated url is such...</p> <pre><code>https://www.google.com/accounts/o8/ud?openid.mode=checkid_setup&amp;openid.ns=http://specs.openid.net/auth/2.0&amp;openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&amp;openid.identity=http://specs.openid.net/auth/2.0/identifier_select&amp;openid.return_to=http://learn.local/openid/return.php&amp;openid.realm=http://learn.local/openid/index.html&amp; </code></pre> <p>However, you end up at a page requested is invalid. And a nice 400 Bad Request.. any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload