Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error getting tokens #39

Closed
henryoliver opened this issue Apr 8, 2018 · 3 comments
Closed

Error getting tokens #39

henryoliver opened this issue Apr 8, 2018 · 3 comments

Comments

@henryoliver
Copy link

Any help guys I would appreciate it! Thanks!

      if (error) throw new Error('Error getting tokens:', error);
                 ^

Error: Error getting tokens:
    at oauthClient.getToken (/home/pi/google-assistant-nodejs/node_modules/google-assistant/components/auth.js:73:24)
    at /home/pi/google-assistant-nodejs/node_modules/google-auth-library/lib/auth/oauth2client.js:154:5
    at Request._callback (/home/pi/google-assistant-nodejs/node_modules/google-auth-library/lib/transporters.js:106:7)
    at Request.self.callback (/home/pi/google-assistant-nodejs/node_modules/request/request.js:186:22)
    at Request.emit (events.js:180:13)
    at Request.<anonymous> (/home/pi/google-assistant-nodejs/node_modules/request/request.js:1163:10)
    at Request.emit (events.js:180:13)
    at IncomingMessage.<anonymous> (/home/pi/google-assistant-nodejs/node_modules/request/request.js:1085:12)
    at Object.onceWrapper (events.js:272:13)
    at IncomingMessage.emit (events.js:185:15)

const record = require('node-record-lpcm16');
const Speaker = require('speaker');
const path = require('path');
const GoogleAssistant = require('google-assistant');
const speakerHelper = require('./speaker-helper');

const config = {
  auth: {
    keyFilePath: path.resolve(__dirname, '/home/pi/credentials.json'),
    savedTokensPath: path.resolve(__dirname, 'tokens.json'), // where you want the tokens to be saved
  },
  conversation: {
    audio: {
      sampleRateOut: 24000, // defaults to 24000
    },
    lang: 'en-US', // defaults to en-US, but try other ones, it's fun!
  },
};
@endoplasmic
Copy link
Owner

Couple of options:

  1. Your keyFilePath is a little wacky. If you want to use an absolute path, you don't need to use the path module at all. Just set it as /home/pi/credentials.json and remove the path.resolve stuff.

  2. Your credentials.json file isn't right, it should look something like this:

{  
   "installed":{  
      "client_id":"xxxxxxx.apps.googleusercontent.com",
      "project_id":"xxxxxx",
      "auth_uri":"https://accounts.google.com/o/oauth2/auth",
      "token_uri":"https://accounts.google.com/o/oauth2/token",
      "auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs",
      "client_secret":"xxxxxx",
      "redirect_uris":[  
         "urn:ietf:wg:oauth:2.0:oob",
         "http://localhost"
      ]
   }
}

@henryoliver
Copy link
Author

Thank you @endoplasmic! Will test it tonight and let you know soon!

@henryoliver
Copy link
Author

@endoplasmic worked! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants