aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-01-23 23:07:25 -0500
committerDeterminant <[email protected]>2019-01-23 23:07:25 -0500
commit9eec5b0d0ca748a73abe23511688bbba9b906c22 (patch)
tree48f610df290336edae8a620d945f8cc156e34a89
parent4ef8618ffba5a66fea2020f367f5533efeaa5b0c (diff)
figure out how to do oauth2 and access Google Calendar data
-rw-r--r--background.js3
-rw-r--r--index.html9
-rw-r--r--manifest.json21
-rw-r--r--oauth.js13
4 files changed, 46 insertions, 0 deletions
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 @@
+<html>
+ <head>
+ <title>chromicle</title>
+ <script type="text/javascript" src="oauth.js"></script>
+ </head>
+ <body>
+ <ul id="test"></ul>
+ </body>
+</html>
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);
+ });
+ });
+ });
+};