GOOGLETASKS AUTHENTICATION
Warning … this post will probably come across as a rant … but, gees, the instructions provided for getting google task authentication / certificates are confusing. It took me a couple of attempts as well as taking detailed notes the last time to get it all working.
I did find the MMM-Buller instructions slightly easier to follow, but the actual module display was poor :(. I got my certificate by following Buller instructions and then used it for the MMM-GoogleTasks.
Here we go … from https://github.com/da4throux/MMM-Buller
Step 0
Have a gmail account (nice start!)
Step 1
Follow this instruction to Turn on the Google Tasks API and get your file credentials.json
And this is where you disappear down a rabbit hole. I am unsure how deep this rabbit hole is.
Rabbit Hole 1 - turn on google tasks API
First linked page is a google help page - has these pre-reqs
a. Node.js & npm installed.
b. A Google Cloud Platform project with the API enabled.
To create a project and enable an API, refer to Create a project and enable the API
c. Authorization credentials for a desktop application. To learn how to create
credentials for a desktop application, refer to Create credentials
d. A Google account with Google Tasks enabled.
I have a) and d). I need to create a project for b)
Rabbit Hole 2 - Create Project / Enable API
Another google help page (these pages are actually pretty good instructions)
a. Create Project (I called mine 'MMBuller-GoogleTask', updated the project ID
to sort of match and went with a location of 'No organization')
I got lots of system complains about my project ID … has to be lower case, has to be available!
b. Enable the API
Great, another link and a deeper rabbit hole. And you have to search for the API. Sigh … none of the above actually include the name of the API to enable. It could be Aardvark API and I am not joking
- I searched for tasks … and hit 4 options with the first one being Tasks API
- Seems like a fair option … lets go with that one
- Click on the API box and then click enable
And that is part B of RH1. Moving onto part C.
Rabbit Hole 3 - create credentials
Straight off … you have three options (API Key, OAuth Client ID, Service account). Which one? I knew from prior MM google tasks googling that OAuth Client ID was the way to go … I just don’t know why it is the way to go. No problem … I feel like a bull with a ring in its nose. Here I go following directions.
Another unguided decision to make … what type of application do I have that needs to create credentials? Options include web, android, iOS, Chrome app, Desktop app, TV something and MS app. I think my choice is between web and desktop. What type of app is magic mirror. It feels to me that it could be either of them.
I went with desktop and will reserve the right (ha!) to create web credentials (if required).
First time through it wouldn’t / didn’t present the fields that the instructions implied (I couldn’t get application type to come up). I had to fill in the Consent Screen information (just put in my email address a bunch of times and clicked ‘save and continue’. I am now back to trying the to create credentials again … and it is showing the application type). I called it BullerGTasks … clicked create … and …
BINGO! I have Client ID and Client Secret (shhhh).
Crikey - I might have escaped the rabbit hole.
Wait … not so fast. I am just done with the pre-reqs :(
Step 3 - Installing the Client Library
These install instructions could have been a little better. It is all there, but a little bit scattered.
First off, you know that client secret file you created … you need to rename it to credentials.json and put it in the root folder for the module. That isn’t mentioned until you get to the TROUBLE SHOOTING section. No critical instructions about that file … but the developer fully expected you to fail to realize that you needed to so included it ‘trouble shooting’. Why not just put those instructions at the top?
Anyway, copy your secret cred file and rename it to ‘credentials.json’
Then follow the directions (install, create file, etc).
First off, it says to install the googleapi …
npm install googleapis@39 --save
Don’t do that. Drop everything after the @39 so you get the latest version.
npm install googleapis
Create a file (index.js - the code is on the instruction to Turn on the Google Tasks API page) and then run it in your SSH console with …
node index.js
Make sure you run it from inside MMM-Buller directory. This will give you a url … open browser, enter URL, and you should get a magic code. I didn’t because app wasn’t verified. Stuff that! I just hit continue / trust app.
The index.js is still running … waiting for the magic code from the URL. Unfortunately, by the time I had gone to a browser, clicked through to the code, etc … the index.js had moved on and I was back to the command prompt (SSH).
I ran it again, pasted the prior code … and index.js created a token.json file for me.
Note that the token.json file contained the IDs that the MMM-GoogleTasks module needed. No need to go through all of this guff again to get GoogleTasks working.
Step 4538
Now I think I am finally ready to install Buller.