我为少数 OAuth2-OpenIdConnect 提供者实现了 OpenIDConnect 身份验证/配置/联合的客户端。但我无法让 Google OpenID People https://developers.google.com/+/api/openidconnect/getOpenIdConnect工作。
我对 OpenID 身份验证/授权的第一部分没有任何问题,并且可以毫无问题地从 JSONWEBtoken 获取身份令牌。尽管如此,我还是无法访问 $identityApiUrl。奇怪的是,旧的 google 的 userinfo API 可以工作!!!只有新的失败并出现授权错误。
对于 PeopleAPI,我使用了重用 access_token 的承载令牌,我得到了我的授权请求。就像我对旧 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."
}
}