conveyal / analyst-server

DEPRECATED; see https://github.com/conveyal/analysis-ui
MIT License
37 stars 6 forks source link

Authentication #243

Open ansoncfit opened 8 years ago

ansoncfit commented 8 years ago

On the new authentication, we were trying this in app.js:

var analystCreds = require('request');
console.log('analyst_key: '+ process.env.analyst_key);
console.log('analyst_secret: '+ process.env.analyst_secret);
console.log(btoa(process.env.analyst_key +':'+ process.env.analyst_secret));

var analystReqOpts = {
  url: 'https://analyst.conveyal.com/oauth/token',
  method: 'POST',
  timeout: 10000,
  auth: {
    'user' : process.env.analyst_key,
    'pass' : process.env.analyst_secret
  },
  headers: {
    'content-type'  : 'application/x-www-form-urlencoded'
  },
  body: 'grant_type=client_credentials'
};

analystCreds(analystReqOpts, function (error, response, body){
    console.log(JSON.stringify(response));});

and getting a 401.

I thought we were including grant_type=client_credentials in the body (see the code from app.js I posted above), but my skills here are limited.