From 9eec5b0d0ca748a73abe23511688bbba9b906c22 Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 23 Jan 2019 23:07:25 -0500 Subject: figure out how to do oauth2 and access Google Calendar data --- background.js | 3 +++ index.html | 9 +++++++++ manifest.json | 21 +++++++++++++++++++++ oauth.js | 13 +++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 background.js create mode 100644 index.html create mode 100644 manifest.json create mode 100644 oauth.js diff --git a/background.js b/background.js new file mode 100644 index 0000000..76043c6 --- /dev/null +++ b/background.js @@ -0,0 +1,3 @@ +chrome.browserAction.onClicked.addListener(function() { + chrome.tabs.create({url: 'index.html'}); +}); diff --git a/index.html b/index.html new file mode 100644 index 0000000..a167340 --- /dev/null +++ b/index.html @@ -0,0 +1,9 @@ + + + chromicle + + + + + + diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..d97895f --- /dev/null +++ b/manifest.json @@ -0,0 +1,21 @@ +{ + "name": "chromicle", + "version": "0.1", + "description": "Chrome extension to find out your wasted part of life from Google Calendar.", + "background": { + "scripts": ["background.js"], + "persistent": false + }, + "browser_action": { + "default_title": "chromicle" + }, + "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAopUFqJFPozQrEnkBKa4iUAcJQTpVFfqe2+fiOZXL1NODVFr2w8gE6RriML/gQab99ZQ1CFYYpOHh5VFS+7rdTBwiNr5C01ZlLpfBZuH/RBVHwCxmNdFqmY5vFqMCGWdKWgrMOyvdl+vVNkr0T8aHadiQg18olaAYEqYzz+SDv371DC5IHssL2q+7fP4YsKmmQ1LT6NVpBh8Oq3qUCtAlayRrLOcvDRTyb3iT0RcUMIUlS1lp9otkkn7xopUEwwNAl+od5B4Wklv2iJxJ6mZKWvZDoFyC9Vr44+xdHrqGOFwMLLF1r4FFGFzyvk2bU1QmXkj+4ScX+FvrCZQdfRJ+cwIDAQAB", + "oauth2": { + "client_id": "17405925155-cs61263jgrsj4kt5usv41riph3oh8mq8.apps.googleusercontent.com", + "scopes": ["https://www.googleapis.com/auth/calendar.readonly"] + }, + "permissions": [ + "identity" + ], + "manifest_version": 2 +} diff --git a/oauth.js b/oauth.js new file mode 100644 index 0000000..96ae811 --- /dev/null +++ b/oauth.js @@ -0,0 +1,13 @@ +window.onload = function() { + chrome.identity.getAuthToken({interactive: true}, function(token) { + fetch('https://www.googleapis.com/calendar/v3' + '/users/me/calendarList' + '?access_token=' + token, + { method: 'GET', async: true }).then((response) => response.json()).then(function(data) { + var test = document.getElementById('test'); + data.items.map(e => e.summary).forEach(function(e) { + var entry = document.createElement('li'); + entry.innerText = e; + test.appendChild(entry); + }); + }); + }); +}; -- cgit v1.2.3-70-g09d2