0
我正在使用Google Calendar API的web应用程序(现在,我只是想能够检索并显示日历中的事件列表),但我无法正确地制作API调用。从技术上讲,这是成立的,但我没有得到回应,因为我没有通过身份验证。我知道我需要OAuth凭证,但我不确定在哪里设置这些(我已经有我的客户端ID和密码)。无法在流星中使用Google Calendar API - OAuth问题?
这里是我的代码,在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/[email protected]/events", function(error, response) {
console.log(response);
});
},
});
而在body.html
,我叫test
使用{{test}}
随机的地方。 (我不知道这是否是正确的代码,因为我是新来的流星)
至于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调用。我错过了什么?
您绝对需要验证。但首先 - 你不能从客户端进行同步HTTP调用。所以你应该把'console.log'放在异步回调中。 –
好的,修正了这个问题。现在问题似乎实际上来自OAuth。 – Technicolor