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

Auth call - 403 error

Hi,

 

I need some urgent help here. When I make a oAuth2.0 call from the browser using the url as below,

I do get a response with a value to 'code' query string parameter, which I successfully use in subsequent calls.

 

https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=XXXX&redirect_uri=http%3A%2F%2F... nutrition heartrate location nutrition profile settings sleep social weight

 

However, when I try to make the same call programatically through java code, I get a 403 error.

 

 

        URL nurl1 = new URL("https://www.fitbit.com/login?redirect=%2Foauth2%2Fauthorize%3Fresponse_type%3Dcode%26client_id%XXXXX...
        HttpsURLConnection conn1 = (HttpsURLConnection) nurl1.openConnection();
        conn1.setRequestMethod("POST");
        conn1.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        String authString1 = "XXXXX"+":"+"XXXXXXXXXXXXXXX";        
        String authStringEnc1 = new String(Base64.encodeBase64(authString1.getBytes()));        
        conn1.setRequestProperty("Authorization", "Basic " + authStringEnc1);
        System.out.println("the response code     "+conn1.getResponseMessage());

 

Pls suggest a way forward

 

 

 

Best Answer
0 Votes
1 REPLY 1

@PalsN wrote:

Hi,

 

I need some urgent help here. When I make a oAuth2.0 call from the browser using the url as below,

I do get a response with a value to 'code' query string parameter, which I successfully use in subsequent calls.

 

https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=XXXX&redirect_uri=http%3A%2F%2F... nutrition heartrate location nutrition profile settings sleep social weight

 

However, when I try to make the same call programatically through java code, I get a 403 error.

 

 

        URL nurl1 = new URL("https://www.fitbit.com/login?redirect=%2Foauth2%2Fauthorize%3Fresponse_type%3Dcode%26client_id%XXXXX...
        HttpsURLConnection conn1 = (HttpsURLConnection) nurl1.openConnection();
        conn1.setRequestMethod("POST");
        conn1.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        String authString1 = "XXXXX"+":"+"XXXXXXXXXXXXXXX";        
        String authStringEnc1 = new String(Base64.encodeBase64(authString1.getBytes()));        
        conn1.setRequestProperty("Authorization", "Basic " + authStringEnc1);
        System.out.println("the response code     "+conn1.getResponseMessage());

 

Pls suggest a way forward

 

 

 


Can you private message me the non-redacted URL you were using?

Best Answer
0 Votes