获取登录用户的日历Id
问题描述:
我想检索登录的用户的日历事件。 API文档here建议我需要为登录用户传递'primary'作为calendarId。获取登录用户的日历Id
因此,URL成为https://www.googleapis.com/calendar/v3/calendars/primary/
我对这个URL得到一个401。
GET https://www.googleapis.com/calendar/v3/calendars/primary/ 401()
有人可以请建议我做错了什么。
答
我认为你需要传递不同的calendarId(日历的电子邮件地址)。要获取您的日历ID,您可以按照指定的步骤here。
要知道你遇到的错误,这里是关于401: Invalid Credentials的文档。
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization",
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
建议采取的行动:
- 使用长寿命的刷新令牌获取新的访问令牌。
- 如果失败,请指导用户通过OAuth流程,如Authorizing requests with OAuth 2.0中所述。
- 如果您看到这是服务帐户,请检查您是否已成功完成service account
page中的所有步骤。