首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >谷歌的OpenID实现..400个错误请求

谷歌的OpenID实现..400个错误请求
EN

Stack Overflow用户
提问于 2012-06-07 03:12:50
回答 1查看 687关注 0票数 2

所以我正在努力掌握OpenID,我觉得我理解了这个理论,等等。现在该实现它了。我有一个非常基本的设置,可以向google提供商地址发送curl请求。

代码语言:javascript
复制
https://www.google.com/accounts/o8/id

解析返回的XRDS xml文件

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)">
  <XRD>
    <Service priority="0">
      <Type>http://specs.openid.net/auth/2.0/server</Type>
      <Type>http://openid.net/srv/ax/1.0</Type>
      <Type>http://specs.openid.net/extensions/ui/1.0/mode/popup</Type>
      <Type>http://specs.openid.net/extensions/ui/1.0/icon</Type>
      <Type>http://specs.openid.net/extensions/pape/1.0</Type>
      <URI>https://www.google.com/accounts/o8/ud</URI>
    </Service>
  </XRD>
</xrds:XRDS>

在从XRDS文档中检索到google的实际提供者后,我使用此函数重定向...

代码语言:javascript
复制
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->URLs['return_to'];
    $params['openid.realm'] = $this->URLs['realm'];

    $join = stripos($this->URLs['openid_server'], '?') ? '&' : '?';
    $redirect_to = $this->URLs['openid_server'] . $join . $this->array2url($params);
    if (headers_sent()){ // Use JavaScript to redirect if content has been previously sent (not recommended, but safe)
        echo '<script language="JavaScript" type="text/javascript">window.location=\'';
        echo $redirect_to;
        echo '\';</script>';
    }else{  // Default Header Redirect
        header('Location: ' . $redirect_to);
    }
}

array2url是一个简单的函数,它将assoc数组$params转换为附加到查询字符串。

生成的url是这样的。

代码语言:javascript
复制
https://www.google.com/accounts/o8/ud?openid.mode=checkid_setup&openid.ns=http://specs.openid.net/auth/2.0&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&openid.return_to=http://learn.local/openid/return.php&openid.realm=http://learn.local/openid/index.html&

但是,您所请求的页面是无效的。一个不错的400坏请求..有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-06-07 03:51:57

总而言之,我觉得自己太愚蠢了!归根结底就是正确设置我的领域。我有一个领域,导致我的返回地址超出了可以说的可用的“范围”。对于将来遇到400错误的人来说,它可能是..

代码语言:javascript
复制
$openid->SetReturnAddress(('http://learn.local/openid/return.php')); //.return_to
$openid->SetDomain(('http://learn.local/openid/index.html')); //Realm

配置不佳的领域..面部美容

现在是..。

代码语言:javascript
复制
$openid->SetDomain(('http://learn.local')); //Realm
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10920627

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档