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

Having trouble with redirect_uri via httr in R

ANSWERED

Hello,

 

I'm trying to access my personal application via R using httr and I am getting a redirect_uri error. Currently employing this nifty script I found on Github to try and access the application data:

 

fitbit_endpoint <- oauth_endpoint(  request = "https://api.fitbit.com/oauth2/token",  authorize = "https://www.fitbit.com/oauth2/authorize",  access = "https://api.fitbit.com/oauth2/token")myapp <- oauth_app(  appname = "data_access",  key = "Your OAuth 2.0 Client ID", 
  secret = "Your Client (Consumer) Secret")

# 2. Get OAuth tokenscope <- c("sleep","activity")  # See dev.fitbit.com/docs/oauth2/#scopefitbit_token <- oauth2.0_token(fitbit_endpoint, myapp,  scope = scope, use_basic_auth = TRUE)

# 3. Make API requestsresp <- GET(url = "https://api.fitbit.com/1/user/-/sleep/date/2016-01-01.json", 
  config(token = fitbit_token))content(resp)

 So, anyway, my app is set up as "personal" and "browser" with a callback URI as http://localhost:1410/

 

Any idea what's amiss?


Thanks

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

<face palm>

authorization_uri needs to be set to localhost:14010 and the variable in R script also needs to reflect that.

😞

Now I just have to get the Rcurl fetch to work.

 

View best answer in original post

Best Answer
0 Votes
9 REPLIES 9

You need to specify your redirect_uri in your app settings at https://dev.fitbit.com/apps . You should also specify it as a URL parameter on the OAuth 2.0 authorization page.

 

If you app is just for you, "Personal" is the correct OAuth 2.0 app type. You can ignore the OAuth 1.0a app type.

Best Answer
0 Votes

What do you mean authorization page? I'm not really developing an app that people will use or navigate. I just want to scrape all of the raw data out of my account so I can develop a data product for myself.

 

So far I have established an account, set it to browser, personal, read-only and set callback URI to http://localhost:1410/.

 

In my R script I've set set all of the parameters as noted in the script above, replacing my key/token as necessary.

 

This is what I get when R tries to authenticate: a browser window opens up to the fitbit auth page and throws this error: 

The app you're trying to connect did not provide valid information to Fitbit. Please report this issue to them.

Developer information: invalid_request - Missing response_type parameter value

Best Answer

<face palm>

authorization_uri needs to be set to localhost:14010 and the variable in R script also needs to reflect that.

😞

Now I just have to get the Rcurl fetch to work.

 

Best Answer
0 Votes

@wfio wrote:

This is what I get when R tries to authenticate: a browser window opens up to the fitbit auth page and throws this error: 

The app you're trying to connect did not provide valid information to Fitbit. Please report this issue to them.

Developer information: invalid_request - Missing response_type parameter value


Given the error message, you need to specify a "response_type" value for the authorization page (the page that asks for permission). See https://dev.fitbit.com/docs/oauth2/#authorization-page

Best Answer
0 Votes

I'm struggling with the same issue you were - when you say "the variable in R script", which variable do you mean? Could you paste your working code? Thanks!

Best Answer
0 Votes

 

Well that doesn't really help. I set http://localhost:1410/ as Callback URL as suggested but the error "no valid redirect_uri" remains. Also, I see no way to set this parameter in the httr package.

Best Answer
0 Votes

Could someone please explain this solution! I have the same problem, i.e. an error message saying "Developer information: invalid_request - Invalid redirect_uri parameter value".

Best Answer
0 Votes

More specifically, what is "authorization_uri" supposed to mean? And which 'variable is supposed to reflect that'? I wonder how such an ambiguous answer could be flagged "a solution"!?

Best Answer
0 Votes

@CBSA Most likely meant "redirect_uri", see Jeremiah's post above. Callback url and redirect_uri parameter need to be an exact match.

Andrew | Community Moderator, Fitbit

What motivates you?

Best Answer
0 Votes