使用 API-Key 而不是 OAuth 2.0 对谷歌 API 进行身份验证

时间:2021-07-23 10:05:12

标签: postman google-calendar-api

https://developers.google.com/calendar/api/v3/reference/calendarList/list?apix=true#auth 我可以看到,我可以使用 OAuth2 和 API-Key 对 calendarList 端点进行身份验证 enter image description here

我对邮递员和 OAuth2 的第一次测试效果很好:我得到了经过身份验证的用户的所有日历的 JSON 列表

现在我通过 API-Key 进行身份验证来测试入口点 我创建了 API 密钥并为此 api 密钥启用了日历: enter image description here

问题:

我已经使用 postman 和 Auth-Type=ApiKey 以及参数 key=MYAPIKEY 对其进行了测试,但总是收到错误 401“请求缺少所需的身份验证凭据” enter image description here

是否有人有(邮递员)示例来使用 API 密钥访问谷歌日历 API?

1 个答案:

答案 0 :(得分:1)

API 密钥仅用于访问公共数据,而非私人用户数据。

为了与邮递员一起使用 api 密钥,您只需接受请求并在末尾添加 key=YourKEY

以下是一个很好的示例,但不幸的是,API 密钥和公共日历目前存在问题。需要授权而不仅仅是 api 密钥194427607

https://www.googleapis.com/calendar/v3/calendars/en.danish%23holiday%40group.v.calendar.google.com?key=[YOUR_API_KEY]

未经授权您将无法使用日历列表calendarlist.list 在文档中声明您必须被授权作为其私人用户数据。

enter image description here

相关问题