I wrote a program in node.js to fetch the access token to call the box apis, unfortunately I am getting an error "invalid_client" which is either "client ID or secret are wrong" as per the documentation. I am pretty sure that both client id and secret are correct since it worked fine for me while doing ajax calls from UI.
Here is the piece of code I am using
{{{
if(queryData && queryData.code) {
var code = queryData.code;
var data = {
"grant_type" : 'authorization_code',
"client_id" : 'alpha-numeric-id',
"client_secret" : 'alpha-numeric-secret',
"code": 'actual-code-given-in-redirect-uri'
};
var options = {
'url': 'https://www.box.com/api/oauth2/token',
'proxy': 'http://corporate-proxy-url:port',
'headers': {
'accept': 'application/json',
'accept-language': 'en'
},
'json': data,
'timeout': 5000
};
request.post( options, function ( err, response, body ) {
if ( err ) {
console.log("====error====");
} else {
console.log("====success=====");
console.log(response.statusCode);
console.log(body);
}
} );
}
}}}
It would be helpful if someone could figure out whats wrong in my code.
Thanks in advance.