// Client ID and API key from the Developer Console
const CLIENT_ID = '265508904196-9ctubpcu3melvg9tj9td28e04vr4gbva.apps.googleusercontent.com';
const API_KEY = 'AIzaSyDr296X714mF87r1omi70Av-f03m7NWL0s';
// Array of API discovery doc URLs for APIs used by the quickstart
const DISCOVERY_DOCS = ['https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest'];
// Authorization scopes required by the API; multiple scopes can be
// included, separated by spaces.
const SCOPES = 'https://www.googleapis.com/auth/calendar.readonly';
new Vue({
el: '#app',
data() {
return {
items: undefined,
api: undefined,
authorized: false
}
},
created() {
this.api = gapi;
this.handleClientLoad();
},
methods: {
/**
* On load, called to load the auth2 library and API client library.
*/
handleClientLoad() {
this.api.load('client:auth2', this.initClient);
},
/**
* Initializes the API client library and sets up sign-in state
* listeners.
*/
initClient() {
let vm = this;
vm.api.client.init({
apiKey: API_KEY,
clientId: CLIENT_ID,
discoveryDocs: DISCOVERY_DOCS,
scope: SCOPES
}).then(_ => {
// Listen for sign-in state changes.
vm.api.auth2.getAuthInstance().isSignedIn.listen(vm.authorized);
});
},
/**
* Sign in the user upon button click.
*/
handleAuthClick(event) {
Promise.resolve(this.api.auth2.getAuthInstance().signIn())
.then(_ => {
this.authorized = true;
});
},
/**
* Sign out the user upon button click.
*/
handleSignoutClick(event) {
Promise.resolve(this.api.auth2.getAuthInstance().signOut())
.then(_ => {
this.authorized = false;
});
},
/**
* Print the summary and start datetime/date of the next ten events in
* the authorized user's calendar. If no events are found an
*...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.