无法在Meteor中使用Google Calendar API - OAuth问题?

时间:2017-06-18 14:23:53

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

我正在开发使用Google Calendar API的网络应用程序(目前,我只是希望能够从日历中检索并显示事件列表),但我还没有能够正确地进行API调用。从技术上讲,它已经制作完成,但由于我未经过身份验证,因此无法获得回复。我知道我需要OAuth凭据,但我不确定在哪里设置它们(我已经拥有了我的客户端ID和密码)。

以下是我的代码body.js

import { Template } from 'meteor/templating';
import { HTTP } from 'meteor/http'

import './body.html';

Template.body.helpers({
    test() {
        HTTP.get("https://www.googleapis.com/calendar/v3/calendars/michelleran707@gmail.com/events", function(error, response) {
            console.log(response);
        });
    },
});

body.html中,我使用test随机调用{{test}}。 (我不确定这是否是正确的代码,因为我是Meteor的新手。)

至于OAuth,我四处搜索,这是我最终使用的代码:

import { Accounts } from 'meteor/accounts-base'

Accounts.loginServiceConfiguration.remove({
  service: "google"
});

Accounts.loginServiceConfiguration.insert({
  service: "google",
  clientId: "my id",
  secret: "my secret"
});

我已将这两个JavaScript文件导入main.js。但是,我仍然无法正确进行API调用。我错过了什么?

1 个答案:

答案 0 :(得分:0)

已解决 - 我修改了官方Quickstart的代码并让OAuth正常工作。好像我刚开始时忽略了这一点。