Some noob questions (token, authentication protocol, javastrava, callback domain, reachable dataset)

2,080 views
Skip to first unread message

Luis Alfonso González

unread,
Jan 13, 2016, 7:36:49 PM1/13/16
to Strava API
Hello everyone:

I'm trying to use javastrava (https://github.com/danshannon/javastravav3api) to get access to Strava dataset. The point is that I just need data to process this data locally (for example I want to make some statistics and graphs) and I need no users authenticating into some web app. I already have My API Application page (https://www.strava.com/settings/api) with "Client ID", "Client Secret" and "Your Access Token (permisions: public)".  And now the questions:

1. With what shoud I fill "Authorization Callback Domain"? As I said I'm just making requests from my own computer in order to obtain data. I've read it should work with "localhost" but I'm not sure if that's true. It may sound silly but when it comes client-server stuff I'm a total noob.
2. About javastrava implementation and what the README says about connecting. I've tried the following:

Integer clientID=the-clientID-i-got-in-registration;
String clientSecret=the-clientSecret-i-got-in-registration;
String accessToken=the-accessToken-i-got-in-registration;
AuthorisationService service = new AuthorisationServiceImpl();
Token token = service.tokenExchange(clientID,clientSecret,accessToken);
...

But I get this error which I think it has something to do with the Callback Domain:

00:43:57.469 [main] WARN  javastrava.api.v3.rest.util.RetrofitErrorHandler - 400 Bad Request : StravaResponse [message=Bad Request, errors=[StravaAPIError [resource=RequestToken, field=code, code=invalid]]]
javastrava.api.v3.service.exception.BadRequestException: 400 Bad Request : StravaResponse [message=Bad Request, errors=[StravaAPIError [resource=RequestToken, field=code, code=invalid]]]
at javastrava.api.v3.rest.util.RetrofitErrorHandler.handleError(RetrofitErrorHandler.java:113)
at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:242)
at com.sun.proxy.$Proxy16.tokenExchange(Unknown Source)
at javastrava.api.v3.auth.impl.retrofit.AuthorisationServiceImpl.tokenExchange(AuthorisationServiceImpl.java:39)
at Prueba.main(Prueba.java:16)
Caused by: retrofit.RetrofitError: 400 Bad Request
at retrofit.RetrofitError.httpError(RetrofitError.java:40)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:388)
at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
... 3 more

3. Can I access public activities from other athletes or just my own dataset?

Thank you in advance

Chris Donahue

unread,
Jan 13, 2016, 8:18:09 PM1/13/16
to Luis Alfonso González, Strava API
For (1) you can use localhost (see http://strava.github.io/api/v3/oauth/ for more details)

I am not sure about the error you are getting for (2) - I would check with Dan Shannon or other users of the Javascript code to see if they have seen this.

For (3), you can't get detailed information about activities not owned by the authenticated athlete. However you can get segment efforts for a given leaderboard, and lists of friends' activities (in summary form). In general, the permissions are documented here: http://strava.github.io/api/v3/activities/

-Chris Donahue (Strava Engineer)


--
You received this message because you are subscribed to the Google Groups "Strava API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to strava-api+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luis Alfonso González

unread,
Jan 14, 2016, 3:00:39 PM1/14/16
to Strava API, lagonza...@gmail.com

Thank you for your answers Chris. If you can help me I'm still confused:

About (1), I've read the documentation and what I understand is that you exchange your ID, ClientSecret and Code ("Your Access Token" in My API Application page) for the real token in order to access Strava dataset. I do not need others to use my application, just me, so I guess those are just the things I need. Then, and correct me if I'm wrong, since I'm trying to access from my local machine and using Javastrava in Eclipse I should fill the "Authorization Callback Domain" option with localhost and port used by Eclipse to listen to HTTP connections. Right? (someone asked me in other thread to put 8080 as shown in the image attached). The other information is irrelevant because is just for a web app which is not what I want to do. Right? (As I said networks are not my thing, I'm really a noob in this area).

About (2) I've already asked in the GitHub project page but I'm pretty sure this has something to do with configuring the things in (1).

(3) is clear. Thank you!

Chris Donahue

unread,
Jan 14, 2016, 3:36:57 PM1/14/16
to Luis Alfonso González, Strava API
Luis, I'm not totally sure what is not working for you, but importantly, for each athlete that is going to use your application (in your case, just you), you need to authenticate using your Strava credentials to authorize your app to access your data (see https://www.strava.com/oauth/authorize?client_id=9&response_type=code&redirect_uri=http://localhost/token_exchange.php&approval_prompt=force for an example of the authorization page). Then on the redirect URL you specify, you can save the authorization code that Strava sends back. That authorization code is what's required to make API calls on behalf of a user.

Luis Alfonso González

unread,
Jan 14, 2016, 5:15:52 PM1/14/16
to Strava API, lagonza...@gmail.com

Ok, you mean clicking in the "OAuth Authorization Page". Then "Authorize". I understand this is to allow my app to access my data (it will appear in "My apps" tab among others who asked me before). When I do this the browser pops up a dialog asking for user/password. Then I use CliendID/Secret and then the browser returns the code which I have to use in order to obtain the user token to access to my detailed data and others summarized data through my application. Understood ;)

I thought the code provided during the registration was the one I had to use. What is this code for then? :S

Now that I've tried with the new code it at least returns HTTP 200 code and understands the token. Now I think I just have to understand the javastrava implementation and play for a while :D

Thank you very much for your time Chris! You've been very helpful
Reply all
Reply to author
Forward
0 new messages