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

Error AuthorizationCode Request

Hello, 

 

I am trying to access FitBit API in Android with Scribe Library. 

 

My application is making a GET request to the server..

 

This is correct and takes me to the right page in a web browser.. 

Something goes wrong afterwards since I do not receive an AuthorizationCode..

 

A possible error could be in the "redirect_uri", or "Callback URL". I have just taken a random URL.. Then I have tested it with a Redirect Checker. I get the message : "Domain doesn't exists." This is the first time I work with a "Callback URL", so I might be missing something fundamental here.. Can anyone point me in the right direction? 

 

What else can go wrong from Authorization Page to Authorization Code?

Best Answer
0 Votes
4 REPLIES 4

Hi,

 

Can you provide us with the error message that you receive?

Best Answer
0 Votes

I get a "java.util.NoSuchElementException" error when trying to use the (retrieved) code further down the line. After testing it seems that the call is correct, but I get nothing back..

 

My callback uri is set in the Settings Page, the Activity and the Manifest (see below). According to me it is not working because I am not in production. I found a similar question on the forum through the following link. 

 

https://community.fitbit.com/t5/Web-API-Development/Callback-URL-when-in-development/td-p/641735

 

The advice is to "set up your application as webapp", but it is not clear to me what steps I exactly have to take. Can you help me with this? 

 

Intent Filter set in the Manifest File. 

<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<data android:scheme="https://fibi22cj69"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>

 

Best Answer
0 Votes

Ideally you should create a Web Application (Backend server to your android client) and have that communicate with the Fitbit Web API. Once you have a hosted web application you can use that as your callback uri, so that you receive requests to that uri and can read the authorization code.

 

If you still wish to just have your android application talk directly to the Fitbit API, you can use a publicly hosted domain e.g. www.fitbit.com as your callback uri and then read the complete uri from the web view of your android application. I am not an expert on Android so cannot vouch for the validity of this approach.

 

You can use the Oauth2 Interactive tutorial as outlined here: https://community.fitbit.com/t5/Web-API-Development/Make-your-OAuth2-0-request-in-less-than-1-minute... to play around with the Fitbit API using something like curl.

Best Answer
0 Votes

Thank you for your reply! 

 

For Development Purposes:

I am currently using callback_uri "http://locallhost.com/". Any issues with doing this only through Android client? Then I can start working with the API to get to know it.. 

 

For Production Purposes: 

My application uses FireBase as a BackEnd system so that is not a problem. So if I understand correctly I need to set up FireBase to talk to the API EndPoint? 

 

Where can I find documentation on this? 

 

Please advice.. 

 

Niels 

Best Answer
0 Votes