为使用Google帐户在Meteor应用程序上注册的用户处理Google日历数据?

全栈

如何为在Meteor应用程序中使用Google帐户注册的用户处理Google日历数据?

例如,我要插入事件或至少发送事件邀请。我的用户使用Google帐户在我的应用程序中注册,但是即使他们注销了,我也想插入事件。下面是我到目前为止拥有的服务器代码,但是它给了我“权限不足”错误。

  if (user && user.services && user.services.google && 
        user.services.google.accessToken) {
    var startTimeUTC = moment.utc(event.startTime, "YYYY-MM-DD HH:mm:ss").format();
    var endTimeUTC = moment.utc(event.endTime, "YYYY-MM-DD HH:mm:ss").format();
    console.log("POSTINGGCAL");
    if (moment.utc().unix() < moment.utc(event.endTime).unix()) {
      console.log("ENTERGCAL");
      var id = Meteor.http.post("https://www.googleapis.com/calendar/v3/calendars/primary/events", {
        'headers' : { 
          'Authorization': "Bearer " + user.services.google.accessToken,
          'Content-Type': 'application/json' 
        },
        'data': {
          "summary": event.name,
          "location": event.location,
          "start": {
            "dateTime": startTimeUTC,
          },
          "end": {
            "dateTime": endTimeUTC,
          },
          "attendees": [
            {
              "email": user.email,
            },
          ]          
        }
      });
    }//end if moment
  }//end if user

错误:

W20141207-16:53:31.883(7)? (STDERR) 
W20141207-16:53:31.883(7)? (STDERR) /Users/.meteor/packages/meteor-tool/.1.0.35.lzatbc++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:206
W20141207-16:53:31.884(7)? (STDERR)                         throw(ex);
W20141207-16:53:31.884(7)? (STDERR)                               ^
W20141207-16:53:31.909(7)? (STDERR) Error: failed [403] {  "error": {   "errors": [    {     "domain": "global",     "reason": "insufficientPermissions",     "message": "Insufficient Permission"    }   ],   "code": 403,   "message": "Insufficient Permission"  } } 
W20141207-16:53:31.909(7)? (STDERR)     at Object.Future.wait (/Users/.meteor/packages/meteor-tool/.1.0.35.lzatbc++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:326:15)
W20141207-16:53:31.910(7)? (STDERR)     at Object.call (packages/meteor/helpers.js:118)
W20141207-16:53:31.910(7)? (STDERR)     at Object.HTTP.post (packages/http/httpcall_common.js:56)
W20141207-16:53:31.910(7)? (STDERR)     at scheduleIt (app/server/scheduler.js:243:28)
W20141207-16:53:31.910(7)? (STDERR)     at app/server/startup.js:16:8
W20141207-16:53:31.911(7)? (STDERR)     at _.extend.forEach (packages/mongo/mongo_driver.js:894)
W20141207-16:53:31.911(7)? (STDERR)     at Cursor.(anonymous function) [as forEach] (packages/mongo/mongo_driver.js:741)
W20141207-16:53:31.911(7)? (STDERR)     at app/server/startup.js:14:20
W20141207-16:53:31.912(7)? (STDERR)     at _.extend.forEach (packages/mongo/mongo_driver.js:894)
W20141207-16:53:31.912(7)? (STDERR)     at Cursor.(anonymous function) [as forEach] (packages/mongo/mongo_driver.js:741)
W20141207-16:53:31.912(7)? (STDERR)     - - - - -
W20141207-16:53:31.913(7)? (STDERR)     at makeErrorByStatus (packages/http/httpcall_common.js:12)
W20141207-16:53:31.913(7)? (STDERR)     at Request._callback (packages/http/httpcall_server.js:95)
W20141207-16:53:31.913(7)? (STDERR)     at Request.self.callback (/Users/.meteor/packages/http/.1.0.8.l3xm0k++os+web.browser+web.cordova/npm/node_modules/request/request.js:122:22)
W20141207-16:53:31.913(7)? (STDERR)     at Request.emit (events.js:98:17)
W20141207-16:53:31.914(7)? (STDERR)     at Request.<anonymous> (/Users/.meteor/packages/http/.1.0.8.l3xm0k++os+web.browser+web.cordova/npm/node_modules/request/request.js:888:14)
W20141207-16:53:31.914(7)? (STDERR)     at Request.emit (events.js:117:20)
W20141207-16:53:31.914(7)? (STDERR)     at IncomingMessage.<anonymous> (/Users/.meteor/packages/http/.1.0.8.l3xm0k++os+web.browser+web.cordova/npm/node_modules/request/request.js:839:12)
W20141207-16:53:31.914(7)? (STDERR)     at IncomingMessage.emit (events.js:117:20)
W20141207-16:53:31.915(7)? (STDERR)     at _stream_readable.js:929:16
W20141207-16:53:31.915(7)? (STDERR)     at process._tickCallback (node.js:419:13)
=> Exited with code: 8

编辑:我在客户端上添加了以下内容,尽管我不再收到任何错误,但日历事件未显示在我的测试Google帐户上。有任何想法吗?

Accounts.ui.config({
    requestPermissions: {
        google: 
        ['https://www.googleapis.com/auth/calendar',
        'https://www.googleapis.com/auth/calendar.readonly',
        'https://www.googleapis.com/auth/userinfo.profile',
        'https://www.googleapis.com/auth/userinfo.email',
        'https://www.googleapis.com/auth/tasks'],
//      forceApprovalPrompt: {google: true}
    }, 
    forceApprovalPrompt: {google: true},
    requestOfflineToken: {google: true},
    passwordSignupFields: 'EMAIL_ONLY',
//      extraSignupFields: []
});

以下流星文档无济于事,因为出现此错误:未捕获的错误:Accounts.ui.config:无效的密钥:forceApprovalPrompt

因斯拉夫科

查看来自Google API的错误:

insufficientPermissions

这意味着您使用的令牌是通过要求用户仅登录而不设置日历访问权限来实现的。

因此,当您让用户登录并使用Meteor.loginWithGoogleaccounts-ui打包时,您需要询问Calendar API范围:

Meteor.loginWithGoogle({requestPermissions: ['https://www.googleapis.com/auth/calendar'], forceApprovalPrompt: true})

或与 accounts-ui

Accounts.ui.config({requestPermissions:{google:['https://www.googleapis.com/auth/calendar']}, forceApprovalPrompt: {google: true}})

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何在Android应用程序上使用Google帐户注册用户

来自分类Dev

在移动应用程序上注册帐户

来自分类Dev

如何在单页Web应用程序上使用python-social-auth通过google oauth2注册用户?

来自分类Dev

关闭Google Chrome应用程序上的串行端口

来自分类Dev

Google Map在Android应用程序上崩溃

来自分类Dev

在Google Earth应用程序上不显示KML

来自分类Dev

是否可以有一个Google云端硬盘帐户,许多用户可以在该帐户中从应用程序上传文件?

来自分类Dev

在Android上打开(Google)日历应用程序网址

来自分类Dev

无法在Blazor WASM Standalone应用程序上使用Google授权登录或获取访问令牌

来自分类Dev

无法在默认的MVC4应用程序上注册新用户

来自分类Dev

无法在默认的MVC4应用程序上注册新用户

来自分类Dev

通过多个Windows 7用户帐户使用Google Drive Sync桌面应用程序

来自分类Dev

我应该在Android应用程序上使用什么来查看日历?

来自分类Dev

使用 Google 日历数据填充 Google Doc 或 HTML 文档

来自分类Dev

如何在Rails应用程序上注册serviceWorker?

来自分类Dev

是否可以有一个Google云端硬盘帐户,许多用户可以在其中从应用程序上传文件?

来自分类Dev

将Google日历和Gmail设置为日历和邮件的“默认应用程序”

来自分类Dev

将Google日历和Gmail设置为日历和邮件的“默认应用程序”

来自分类Dev

使用Google帐户登录的Grails应用程序

来自分类Dev

使用Google帐户登录的Grails应用程序

来自分类Dev

DialogFlow/Actions:允许 Google Assistant 用户从 Actions 应用程序在 Google 日历中创建事件

来自分类Dev

处理WCF服务应用程序上的数据库更改

来自分类Dev

处理数据库或应用程序上的空值?

来自分类Dev

应用程序上的并发用户导致MySQL数据库错误

来自分类Dev

应用程序上的并发用户导致MySQL数据库错误

来自分类Dev

在html5单页应用程序上使用google map时如何管理内存

来自分类Dev

Android上的Google Maps无法在应用程序上运行,但演示很好

来自分类Dev

在电子应用程序上处理松鼠的事件

来自分类Dev

Web应用程序上的会话处理

Related 相关文章

  1. 1

    如何在Android应用程序上使用Google帐户注册用户

  2. 2

    在移动应用程序上注册帐户

  3. 3

    如何在单页Web应用程序上使用python-social-auth通过google oauth2注册用户?

  4. 4

    关闭Google Chrome应用程序上的串行端口

  5. 5

    Google Map在Android应用程序上崩溃

  6. 6

    在Google Earth应用程序上不显示KML

  7. 7

    是否可以有一个Google云端硬盘帐户,许多用户可以在该帐户中从应用程序上传文件?

  8. 8

    在Android上打开(Google)日历应用程序网址

  9. 9

    无法在Blazor WASM Standalone应用程序上使用Google授权登录或获取访问令牌

  10. 10

    无法在默认的MVC4应用程序上注册新用户

  11. 11

    无法在默认的MVC4应用程序上注册新用户

  12. 12

    通过多个Windows 7用户帐户使用Google Drive Sync桌面应用程序

  13. 13

    我应该在Android应用程序上使用什么来查看日历?

  14. 14

    使用 Google 日历数据填充 Google Doc 或 HTML 文档

  15. 15

    如何在Rails应用程序上注册serviceWorker?

  16. 16

    是否可以有一个Google云端硬盘帐户,许多用户可以在其中从应用程序上传文件?

  17. 17

    将Google日历和Gmail设置为日历和邮件的“默认应用程序”

  18. 18

    将Google日历和Gmail设置为日历和邮件的“默认应用程序”

  19. 19

    使用Google帐户登录的Grails应用程序

  20. 20

    使用Google帐户登录的Grails应用程序

  21. 21

    DialogFlow/Actions:允许 Google Assistant 用户从 Actions 应用程序在 Google 日历中创建事件

  22. 22

    处理WCF服务应用程序上的数据库更改

  23. 23

    处理数据库或应用程序上的空值?

  24. 24

    应用程序上的并发用户导致MySQL数据库错误

  25. 25

    应用程序上的并发用户导致MySQL数据库错误

  26. 26

    在html5单页应用程序上使用google map时如何管理内存

  27. 27

    Android上的Google Maps无法在应用程序上运行,但演示很好

  28. 28

    在电子应用程序上处理松鼠的事件

  29. 29

    Web应用程序上的会话处理

热门标签

归档