【问题标题】:how to list a user's calendars from google-calendar with oauth2 3 legged offline access/refresh token如何使用 oauth2 3 腿离线访问/刷新令牌从 google-calendar 列出用户的日历
【发布时间】:2024-01-14 22:09:01
【问题描述】:

非常简单的问题,我似乎找不到任何答案:

我有,通过 oauth2 3 legged 身份验证,userId + accessToken + refreshToken 来访问谷歌用户的日历范围。

现在,我想列出该用户的所有日历。

google 日历 api 参考 (https://developers.google.com/google-apps/calendar/v3/reference/) 谈到了 calendarList,听起来不错……但是……

https://www.googleapis.com/calendar/v3/users//calendarList

这是 3 legged oauth,没有浏览器带有 cookie 存储某种 google 标识符供“我”使用。我需要指定 userId,电子邮件帐户 - 用来识别我想要列出其日历的用户!

有没有办法做这个最琐碎的基本用例?

这个问题 (OAuth2/Google CalDAV - List of calendars for user) 是重复的,自我回答的评论链接描述了一个基于 v2 日历的解决方案,其中包含名为 propfind 和 dav 的东西,我对此一无所知。真的吗?不休息?

啧啧谷歌。啧啧。

【问题讨论】:

    标签: rest google-calendar-api google-oauth


    【解决方案1】:

    嗯,它确实像我认为的那样微不足道和愚蠢:access_token 包含用户信息...在授权中发送 access_token:Bearer 标头就可以了。

    【讨论】:

    • 嗨@nathan,你能粘贴一个你如何解决问题的sn-p吗?如果我没有网络 oauth 流程(我的后端是聊天机器人,所以没有 UI 来提示结束),我无法弄清楚如何让最终用户允许我的服务器端访问最终用户的日历-用户)。谢谢!