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

issue with google-auth.js #59

Open
V1Kin9 opened this issue Apr 20, 2018 · 5 comments
Open

issue with google-auth.js #59

V1Kin9 opened this issue Apr 20, 2018 · 5 comments
Labels
feedback required Submitter Attention Required (otherwise close) investigation Need to investigate strange behaviour/bugs

Comments

@V1Kin9
Copy link

V1Kin9 commented Apr 20, 2018

After running the node google-auth.js ,it requires me to paste my code.I do paste my code from the web,but it doesn't work,and then it returns this:

/home/viking/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/components/auth.js:73
      if (error) throw new Error('Error getting tokens:', error);
                 ^

Error: Error getting tokens:
    at oauthClient.getToken (/home/viking/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/components/auth.js:73:24)
    at /home/viking/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/google-auth-library/lib/auth/oauth2client.js:154:5
    at Request._callback (/home/viking/MagicMirror/modules/MMM-Assistant/node_modules/google-assistant/node_modules/google-auth-library/lib/transporters.js:70:30)
    at self.callback (/home/viking/MagicMirror/modules/MMM-Assistant/node_modules/request/request.js:186:22)
    at Request.emit (events.js:180:13)
    at Request.onRequestError (/home/viking/MagicMirror/modules/MMM-Assistant/node_modules/request/request.js:878:8)
    at ClientRequest.emit (events.js:180:13)
    at TLSSocket.socketErrorListener (_http_client.js:395:9)
    at TLSSocket.emit (events.js:180:13)
    at emitErrorNT (internal/streams/destroy.js:64:8)
@E3V3A E3V3A added investigation Need to investigate strange behaviour/bugs feedback required Submitter Attention Required (otherwise close) labels Apr 22, 2018
@E3V3A
Copy link
Collaborator

E3V3A commented Apr 22, 2018

@V1Kin9
Without fully posting the commands and and the input you gave, there is little I can do.
Please re-open when you have the info.

@Naoki95957
Copy link

Naoki95957 commented May 25, 2018

I have the same error. One thing to note, however I doubt it has much to do with anything, is that the browser it opens closes immediately after I put in an email.

The following is my input/output at the terminal. I covered some of the key with "*"s but they are only letters. The rest of the license is untouched; The forward slash and underscores are part of the code I was given.

pi@raspberrypi:~/MagicMirror/modules/MMM-Assistant/scripts $ node google-auth.js
Opening OAuth URL. Return here with your code.
Paste your code: 4/AAA******_xzggf0AMt1v1QYmcGPA7RYlxiUw_*****************
/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)

@Naoki95957
Copy link

Naoki95957 commented May 25, 2018

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.

@Naoki95957
Copy link

Naoki95957 commented May 26, 2018

So I reinstalled 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).

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?)

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 :)

@Naoki95957
Copy link

Naoki95957 commented May 26, 2018

So I just downgraded 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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feedback required Submitter Attention Required (otherwise close) investigation Need to investigate strange behaviour/bugs
Projects
None yet
Development

No branches or pull requests

3 participants