-1

I have a weird bug going on with my code.

I'm using the simple-oauth2 library (https://github.com/lelylan/simple-oauth2) and my code works fine on Windows.

When I try to run my code on a linux server (raspberry pi zero), the oauth library keeps on returning 404 Not Found for my oauth request (specifically "Access Token Error Not Found" as per the code below).

What's going on?

Code (working with Yelp API):

var fs = require('fs');

var cID = fs.readFileSync('blahblahblah', 'utf8');
var cSecret = fs.readFileSync('blahblahblah2', 'utf8');

var credentials = {
    client: {
        id: cID,
        secret: cSecret
    },
    auth: {
        tokenHost: 'https://api.yelp.com',
        tokenPath: '/oauth2/token'
    }
};

var oauth2 = require('simple-oauth2').create(credentials);
var tokenConfig = {};

module.exports.gimmeMuhToken = function(cb) {
    oauth2.clientCredentials.getToken(tokenConfig, function(error, result) {
        if (error) {
            return console.log('Access Token Error', error.message);
        }
        cb(oauth2.accessToken.create(result).token.access_token); // Return the token
    });
};

Thanks

g00glen00b
  • 34,293
  • 11
  • 80
  • 106
  • if you `nslookup api.yelp.com` on the rPi vs windows, same ip addresses? – Jaromanda X Mar 30 '17 at 07:58
  • I had same error which brought me to this page. However it made me realise my issue. I had my full auth path in 'tokenHost'. I used 'tokenPath' and I was good. Would have been much faster to debug if response was 404 Not Found rather just Not Found. In my mind I was thinking token not found and not the URL. – Mazzi Jun 07 '18 at 01:26

1 Answers1

0

Found the culprit.

It was line endings...

  • Don't add comments as answers. Also, do you have multiple personalities on SO? – Satish Prakash Garg Mar 30 '17 at 17:25
  • @SatishGarg That's irrelevant to the question at hand, but if you really want to know, no. I created a throwaway account and forgot the email used. I simply created a new account. It's asinine that stackoverflow logins are based on email addresses and not user names. – nodumbquestions533867 Apr 05 '17 at 10:01