Skip to content
This repository was archived by the owner on Feb 8, 2019. It is now read-only.
This repository was archived by the owner on Feb 8, 2019. It is now read-only.

Issue with Google-auth.js or possibly something else #67

@Naoki95957

Description

@Naoki95957

Expected Behaviour:
Run Google auth and paste in code to receive tokens

Actual Behaviour:
Error is thrown after code is pasted

Steps to Reproduce the Issue:
Follow instructions with an rpi 3 b+. Initially completed with the most recent versions of node and npm, but then rolled back to npm 5.8.0 and node v9.10.1 to match instructions exactly with reinstall and rebuilt dependencies:

So I was following the instructions and installed and double checked that everything is up to date:

pi@raspberrypi:~/MagicMirror/modules/MMM-Assistant/scripts $ node -v && npm -v
v9.11.1
6.1.0

Then I went through and the dependencies and everything is 'newest', no need for updates 👍

I went ahead and dropped my secret.json in the MMM-Assistant folder and a google-client-secret.json in the assets folder (both are the same file and Google-client-secret.json was missing).

Then I proceeded to run node google-auth.js with a new key/code from google and got the same error

Digging through it the error happens when a request is being made with the transporter. I don't know js but based on the number of if(err)'s there are, I would assume the script would catch us if Oauth key is missing before we continued to make requests.

The throw happens here:

const processTokens = (oauthCode) => {
    if (!oauthCode) process.exit(-1);

    // get our tokens to save
    oauthClient.getToken(oauthCode, (error, tkns) => {
      // if we didn't have an error, save the tokens
      if (error) throw new Error('Error getting tokens:', error);

      tokens = tkns;
      saveTokens();
    });
  };

And the error is returned and given somewhere here:

this.transporter.request({
    method: 'POST',
    uri: uri,
    form: values,
    json: true
  }, function(err, tokens, response) {
    if (!err && tokens && tokens.expires_in) {
      tokens.expiry_date = ((new Date()).getTime() + (tokens.expires_in * 1000));
      delete tokens.expires_in;
    }
    var done = opt_callback || noop;
    done(err, tokens, response);
  });

(this does take a second for the error to appear so could this be a timeout?)

(next day)

I rolled back node and npm in case the versions were the problem and rebuilt the dependencies and am still hitting this error:
(again the '*'s are just letters/numbers)

pi@raspberrypi:~/MagicMirror/modules/MMM-Assistant/scripts $ node google-auth.js
Opening OAuth URL. Return here with your code.
Paste your code: 4/AA*****************************************************
/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/components/auth.js:75
      if (error) throw new Error('Error getting tokens:', error);
                 ^

Error: Error getting tokens:
    at oauthClient.getToken (/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/components/auth.js:75:24)
    at /home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/google-auth-library/lib/auth/oauth2client.js:154:5
    at Request._callback (/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/google-auth-library/lib/transporters.js:106:7)
    at Request.self.callback (/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/request/request.js:185:22)
    at Request.emit (events.js:180:13)
    at Request.<anonymous> (/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/request/request.js:1157:10)
    at Request.emit (events.js:180:13)
    at IncomingMessage.<anonymous> (/home/pi/MagicMirror/modules/MMM-Assistant/node_modules/request/request.js:1079:12)
    at Object.onceWrapper (events.js:272:13)
    at IncomingMessage.emit (events.js:185:15)
pi@raspberrypi:~/MagicMirror/modules/MMM-Assistant/scripts $ node -v && npm -v
v9.10.1
5.8.0

I'm unaware of how far this bug might leech, but I was having a problem prior to this too. Originally in the installation/setup I was instructed to name my Oauth client key as secret.json but it ran into an error saying it was unable to find google-client-secret.json so I renamed my key and dropped it off in the Assets folder. This is the only thing that has deviated from the installation instructions that I am aware of.

I'm planning this project as a gift and really wanna do some cool things like the google assistant. Hope we can find a solution soon :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions