为使用谷歌帐户在Meteor应用程序上注册的用户操纵谷歌日历数据?

为使用谷歌帐户在Meteor应用程序上注册的用户操纵谷歌日历数据?,meteor,google-api,google-calendar-api,Meteor,Google Api,Google Calendar Api,如何为使用谷歌帐户在我的Meteor应用程序上注册的用户操作谷歌日历数据 例如,我想插入事件或至少发送事件邀请。我的用户使用Google帐户在我的应用程序上注册,但我想插入事件,即使他们已注销。下面是我到目前为止的服务器代码,但它给了我“权限不足”的错误 以下Meteor文档没有帮助,因为我遇到了此错误: 未捕获错误:Accounts.ui.config:无效键:forceApprovalPrompt从Google API查看您的错误: insufficientPermissions 这意味着

如何为使用谷歌帐户在我的Meteor应用程序上注册的用户操作谷歌日历数据

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

以下Meteor文档没有帮助,因为我遇到了此错误:
未捕获错误:Accounts.ui.config:无效键:forceApprovalPrompt

从Google API查看您的错误:

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

因此,当您允许用户登录,并使用带有Google的
Meteor.login
帐户ui
软件包时,您需要询问范围:

或与帐户用户界面一起使用

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

我已经编辑了上面的答案,虽然我不再收到任何错误,但日历事件不会显示。有什么想法吗?谢谢这个答案是正确的。请注意,使用Meteor core未提供的非标准accounts ui包存在问题。有关更多信息,请参阅
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: []
});
insufficientPermissions
Meteor.loginWithGoogle({requestPermissions: ['https://www.googleapis.com/auth/calendar'], forceApprovalPrompt: true})
Accounts.ui.config({requestPermissions:{google:['https://www.googleapis.com/auth/calendar']}, forceApprovalPrompt: {google: true}})