【问题标题】:Meteor js requestPermissions not workingMeteor js requestPermissions不起作用
【发布时间】:2019-01-31 21:35:44
【问题描述】:

Meteor js 请求权限不起作用。我想访问谷歌日历,访问令牌没有谷歌日历的权限。我如何才能访问谷歌日历。

【问题讨论】:

  • Meteor.loginWithGoogle({ requestPermissions: [ 'googleapis.com/auth/calendar', 'googleapis.com/auth/userinfo.profile', 'googleapis.com/auth/tasks'], requestOfflineToken: true });
  • 这是我的示例代码。谷歌范围不起作用
  • 如果您想添加信息而不是发布 cmets,请编辑您的主题。
  • 嗨,Bidhan Baral,这个网站可以帮助您解决很多问题,但是为了让人们有机会帮助,创建一个“好”的问题很重要。这意味着不仅要知道how to ask 还要知道how to format 的问题。
  • 就像人们已经说过的那样,编辑您的问题并停止在 cmets 中发布内容。

标签: meteor google-api google-calendar-api


【解决方案1】:

有两件事需要考虑。您需要从 google 获得的正确权限,以及用于访问数据的 API。你没有提供太多细节,所以我不知道你是否也需要移动(Cordova)。

对于您的项目,您需要在 Google Developer Console 中启用日历 API。完成此操作后,您可以选择查看哪些 appId / 授权与您的 API 相关,以便将其添加到您的 Meteor 设置中。

然后,您需要从 OAuth 2.0 范围中选择您需要的确切范围(例如搜索“日历”)并将该范围(整个 url)添加到您的范围数组中。

然后你可以使用 Meteor 的原生 HTTP API 之类的东西来做 GET 或 POST

示例:

 let data = HTTP.call('GET', `https://people.googleapis.com/v1/people/me/connections?pageToken=${res.data.nextPageToken}&personFields=emailAddresses`,
              // let data = HTTP.call('GET', `https:https://www.googleapis.com/calendar/v3/calendars/{... your calendarId}  `,
                {
                  headers: {
                    Authorization: `Bearer ${accessToken}`,
                    Accept: 'application/json'
                  }
                },
                (err, res) => { handle these })

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-27
    • 1970-01-01
    • 2014-10-04
    • 2017-05-27
    • 2017-02-03
    • 1970-01-01
    • 2016-12-18
    相关资源
    最近更新 更多