Google 人 API 未经授权
Google People API unauthorized
我想要自己的 Google 联系人,所以我阅读了 People API documentation,在“授权请求”部分的“获取并使用 API 密钥”它说:
API keys: A request that does not provide an OAuth 2.0 token must send
an API key. The key identifies your project and provides API access,
quota, and reports.
The API supports several types of restrictions on API keys. If the API
key that you need doesn't already exist, then create an API key in the
Console by clicking Create credentials > API key. You can restrict the
key before using it in production by clicking Restrict key and
selecting one of the Restrictions.
所以这看起来很简单,我转到项目页面并创建了一个不受限制的 API 密钥,然后我可以创建此请求 URL:https://people.googleapis.com/v1/people/me?key=API_KEY&personFields=names,使用 API 键就在 URL 中,正如该语句所建议的那样。
After you have an API key, your application can append the query parameter key=yourAPIKey to all request URLs.
但是当我 运行 URL 我在它之前发布 returns 这个:
{
"error": {
"code": 401,
"message": "The request does not have valid authentication credentials.",
"status": "UNAUTHENTICATED"
}
}
我做错了什么? :(
事实证明解决方案非常简单,我觉得很愚蠢,无法使用 API 密钥访问您自己的 Google 联系人或任何其他私人数据,如果您如果您尝试访问任何私人数据,您应该使用 OAuth 2.0 而不是 API 密钥(不像 public YouTube 播放列表,您可以在其中使用 API 密钥)。感谢@Mateo Randwolf
我想要自己的 Google 联系人,所以我阅读了 People API documentation,在“授权请求”部分的“获取并使用 API 密钥”它说:
API keys: A request that does not provide an OAuth 2.0 token must send an API key. The key identifies your project and provides API access, quota, and reports.
The API supports several types of restrictions on API keys. If the API key that you need doesn't already exist, then create an API key in the Console by clicking Create credentials > API key. You can restrict the key before using it in production by clicking Restrict key and selecting one of the Restrictions.
所以这看起来很简单,我转到项目页面并创建了一个不受限制的 API 密钥,然后我可以创建此请求 URL:https://people.googleapis.com/v1/people/me?key=API_KEY&personFields=names,使用 API 键就在 URL 中,正如该语句所建议的那样。
After you have an API key, your application can append the query parameter key=yourAPIKey to all request URLs.
但是当我 运行 URL 我在它之前发布 returns 这个:
{
"error": {
"code": 401,
"message": "The request does not have valid authentication credentials.",
"status": "UNAUTHENTICATED"
}
}
我做错了什么? :(
事实证明解决方案非常简单,我觉得很愚蠢,无法使用 API 密钥访问您自己的 Google 联系人或任何其他私人数据,如果您如果您尝试访问任何私人数据,您应该使用 OAuth 2.0 而不是 API 密钥(不像 public YouTube 播放列表,您可以在其中使用 API 密钥)。感谢@Mateo Randwolf