Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法在Meteor-OAuth问题中使用Google日历API?_Javascript_Meteor_Google Api_Google Calendar Api_Google Oauth - Fatal编程技术网

Javascript 无法在Meteor-OAuth问题中使用Google日历API?

Javascript 无法在Meteor-OAuth问题中使用Google日历API?,javascript,meteor,google-api,google-calendar-api,google-oauth,Javascript,Meteor,Google Api,Google Calendar Api,Google Oauth,我正在开发一个使用GoogleCalendarAPI的web应用程序(目前,我只希望能够从日历中检索和显示事件列表),但我还不能正确地调用API。从技术上讲,它是生成的,但我没有得到响应,因为我没有经过身份验证。我知道我需要OAuth凭据,但我不确定具体在哪里设置这些凭据(我已经有了我的客户端id和密码) 这是我的代码,在body.js中: import { Template } from 'meteor/templating'; import { HTTP } from 'meteor/htt

我正在开发一个使用GoogleCalendarAPI的web应用程序(目前,我只希望能够从日历中检索和显示事件列表),但我还不能正确地调用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调用。我遗漏了什么?

解决了-我修改了官方的代码,使OAuth正常工作。似乎一开始我就忽略了这一点。

您肯定需要auth。但是首先,您不能从客户端进行同步HTTP调用。所以您应该将您的
console.log
放在异步回调中。好的,修复了这个问题。现在问题似乎实际上来自OAuth。