【发布时间】:2021-08-12 15:48:04
【问题描述】:
用于使用 CalDAV 的规范 examples 始终使用用户名/密码身份验证。但是 Nextcloud 支持 OAuth2,因此我想通过 oauth 使用 CalDAV。
我已经对 Google 日历 API 做了同样的事情,但只是改编了 Google 提供的 oauth2client 示例:
client_secrets = 'client_secrets.json'
flow = client.flow_from_clientsecrets(client_secrets, scope="",
message=tools.message_if_missing(client_secrets))
storage = file.Storage('calendar_credentials.dat')
credentials = storage.get()
if credentials is None or credentials.invalid:
credentials = tools.run_flow(flow, storage)
http = credentials.authorize(http=build_http())
将build_http() 替换为caldav.DAVClient 的实例不起作用。内部的request() API 完全不同,调用 caldav 客户端的任何方法都会在被authorize() 包裹时惨遭失败。那么,问题来了:如何将caldav.DAVClient 与oauth2client 结合起来?
关于在 nextCloud 中使用 OAuth 的文档也很少。我找到了this posting,但仍然不清楚具体去哪里了。
【问题讨论】:
标签: python oauth-2.0 caldav nextcloud