获取登录用户的日历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" 
} 
} 

建议采取的行动: