【问题标题】:Google OpenIdConnect People谷歌 OpenIdConnect 人
【发布时间】:2015-02-21 02:19:34
【问题描述】:

我为少数 OAuth2-OpenIdConnect 提供者实现了 OpenIDConnect 身份验证/配置/联合的客户端。但我无法让 Google OpenID People https://developers.google.com/+/api/openidconnect/getOpenIdConnect 工作。

我对 OpenID 身份验证/授权的第一部分没有任何问题,并且可以毫无问题地从 JSONWEBtoken 获取身份令牌。尽管如此,我还是无法访问 $identityApiUrl。奇怪的是,旧的 google 的 userinfo API 可以工作!!!只有新的失败并出现授权错误。

对于 PeopleAPI,我使用了重用 access_token 的 Bearer 令牌,这是我的授权请求。就像我对旧 API 所做的一样。

在从我的代码中使用我使用的 URL 和范围以及错误进行简短提取之后,我在使用 curl 手动重放请求时得到。

问题:

  • OpenIdConnect People API 是否有特殊的身份验证方法?
  • 我需要在应用程序控制台中申请特殊授权吗?

使用 API 的 URL 从代码中提取

    // main IDP configuration URLs
    protected $openidconnect = true;  // Google supports OpenID-Connect
    protected $authTokenUrl  = 'https://accounts.google.com/o/oauth2/auth';
    protected $accessTokenUrl= 'https://www.googleapis.com/oauth2/v3/token';
    // I fail to get Google People OpenIdConnect API to work :(
    //protected $identityApiUrl= 'https://www.googleapis.com/plus/v1/people/me/OpenIdConnect';
    protected $identityApiUrl= 'https://www.googleapis.com/oauth2/v1/userinfo';

    // OAuth2 action-1:  getAuthUrl($state) build authorization token url
    protected $scopes = ['openid','email','profile'];  // request authentication & email

使用 curl 重放请求时的错误代码

[apache@vz-bzh GeoToBe]$ curl -X GET -H "Authorization: Bearer ya29.5ABSl_75eP_zYFho_E-wVjPlZJc1XfY398HZqJjMxvRxBEWteLKZwNeh2v0BPwWuoH1iLpESeBQvFw" https://www.googleapis.com/plus/v1/people/me/openIdConnect
{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured. The API is not enabled for your project, or there is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your configuration.",
    "extendedHelp": "https://console.developers.google.com"
   }
  ],
  "code": 403,
  "message": "Access Not Configured. The API is not enabled for your project, or there is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your configuration."
 }
}

【问题讨论】:

  • 请注意,Google+ API 将在 2019 年全部弃用。

标签: google-oauth google-openid openid-connect


【解决方案1】:

您需要在 Google API 控制台的 APIs & auth 下启用“Google+ API”。

【讨论】:

猜你喜欢
  • 2016-06-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-04
  • 2016-10-08
相关资源
最近更新 更多