ruby-on-rails - 如何解决来自 nylas 的“无法在只读日历上创建事件”的错误?
问题描述
我在我的 Ruby-on-Rails 应用程序中使用 nylas。
我在 nylas 使用谷歌作为我的提供者。我想向谷歌日历添加一个事件。
在谷歌认证后,谷歌返回refresh-token
给我。我用它把这封电子邮件添加到 nylas。最后 nylas 给我发了一个access_token
.
以下几行是我使用的谷歌范围:
openid
email
profile
https://www.googleapis.com/auth/userinfo.email
https://www.google.com/m8/feeds/
https://www.googleapis.com/auth/userinfo.profile
https://mail.google.com/
https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/calendar.events
所以,现在我想使用以下代码段将事件添加到日历中。
nylas = Nylas::API.new(app_id: "My_nylas_app_id",app_secret: "My_nylas_app_secret", access_token: "user_access_token")
calendar = nylas.calendars.first()
nylas.events.create(title: "A fun event!", location: "The Party Zone", calendar_id: calendar.id,when: { start_time: Time.now + 60, end_time: Time.now + 120 }).to_h
并且,上面的代码片段返回以下错误:
D, [2021-05-23T09:49:39.148247 #9070] DEBUG -- : [httplog] Connecting: api.nylas.com:443
D, [2021-05-23T09:49:39.954976 #9070] DEBUG -- : [httplog] Sending: POST http://api.nylas.com:443/events
D, [2021-05-23T09:49:39.955023 #9070] DEBUG -- : [httplog] Data:
D, [2021-05-23T09:49:39.955071 #9070] DEBUG -- : [httplog] Status: 400
D, [2021-05-23T09:49:39.955096 #9070] DEBUG -- : [httplog] Benchmark: 0.391611 seconds
D, [2021-05-23T09:49:39.955136 #9070] DEBUG -- : [httplog] Response:
{"message":"Can't create events on read_only calendar.","type":"invalid_request_error"}
解决方案
推荐阅读
- react-native - 在 React Native 中链接不同的屏幕
- python - 为什么我的点击不能在 pygame 中立即生效?
- javascript - mongodb(节点:37068)UnhandledPromiseRejectionWarning:windows上的nodejs应用程序出错
- python - 用正则表达式匹配不同位置的单词
- ros - 为什么不识别对 URDF 文件的更新?
- python - SQLAlchemy 只连接一列
- r - R函数用阴影绘制不等式
- sublimetext - Sublime Text:在“替换”功能中禁用刷新/替换?
- laravel - 将路由绑定到 laravel7 中的方法(控制器)
- google-cloud-platform - 谷歌云构建:即使用 ls 显示也找不到简单的测试文件