I'm working on a web app that uses the Google Calendar API (for now, I just want to be able to retrieve and display a list of events from a calendar), but I haven't been able to properly make the API call. Technically, it is made, but I don't get a response since I'm not authenticated. I know I need OAuth credentials, but I'm not sure where exactly to set those up (I already have my client id and secret).
Here is my code, in 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);
});
},
});
And in body.html
, I call test
in a random place using {{test}}
. (I'm not sure if this is correct code, since I'm new to Meteor.)
As for OAuth, I searched around and this was the code I ended up using:
import { Accounts } from 'meteor/accounts-base'
Accounts.loginServiceConfiguration.remove({
service: "google"
});
Accounts.loginServiceConfiguration.insert({
service: "google",
clientId: "my id",
secret: "my secret"
});
Both of these JavaScript files I've imported into main.js
. However, I'm still unable to properly make the API call. What am I missing?
Resolved - I tinkered with the code from the official Quickstart and got the OAuth working. Seems like I just overlooked that in the beginning.