无法在 Meteor 中使用 Google 日历 API - OAuth 问题?
Unable to use Google Calendar API in Meteor - OAuth problems?
我正在开发一个使用 Google 日历 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 电话。我错过了什么?
已解决 - 我修改了官方 Quickstart 的代码并使 OAuth 正常工作。看来我一开始就忽略了这一点。
我正在开发一个使用 Google 日历 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 电话。我错过了什么?
已解决 - 我修改了官方 Quickstart 的代码并使 OAuth 正常工作。看来我一开始就忽略了这一点。