Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

401 unauthorized Error

Hi,

 

I was trying to get access token by following the API documentation. Still I am getting 401 Error. can you Please help me out on this ? 

 

Here is my code : 

 

var theUrl="https://api.fitbit.com/oauth2/token";
var params = "client_id=****&grant_type=authorization_code&redirect_uri=********";
xmlHttp.open( "post", theUrl, true);
var clientID = btoa("*****:**************");
console.log("clientID :: "+clientID);
var temp = atob(clientID);
console.log("temp :: "+temp);
xmlHttp.setRequestHeader("Authorization", "Basic "+clientID);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.send( params );

 

Thanks in advance

 

Best Answer
0 Votes
1 REPLY 1

Please provide an HTTP capture of the request and response. It's difficult for us to debug code for languages and libraries we're unfamiliar with. You might try using Runscope to do this.

Best Answer
0 Votes