cancel
Showing results for 
Search instead for 
Did you mean: 

Api v3 Auth Error

Minapps
Mt. Kenya

Hi, I'm having problems exchanging the access code for the token.

I'm in Android Studio in Java.

First I load this URL into my Web View :

String authUrl = "https://www.strava.com/oauth/authorize?" +
"client_id=" + clientId +
"&redirect_uri=" + redirectUri +
"&response_type=code" +
"&scope=activity:read_all";

I get the authorization code.

But then when I load the token exchange URL :

String authUrl = "https://www.strava.com/api/v3/oauth/token?" +
"client_id=" + clientId +
"&client_secret=" + clientSecret +
"&code=" + code +
"&grant_type=" + "authorization_code";

I get this type of message :

 

 

{"message":"Record Not Found","errors":[{"resource":"resource","field":"path","code":"invalid"}]}

 

 

I don't understand why I get it, I've tried different ways but the documentation seems to be outdated?

 

 

In the getting started page they say to do : https://developers.strava.com/docs/getting-started/ 

	curl -X POST https://www.strava.com/oauth/token \
	-F client_id=YOURCLIENTID \
	-F client_secret=YOURCLIENTSECRET \
	-F code=AUTHORIZATIONCODE \
	-F grant_type=authorization_code

And this : https://developers.strava.com/docs/authentication/ 

client_id
required integer, in query
The application’s ID, obtained during registration.
client_secret
required string, in query
The application’s secret, obtained during registration.
code
required string, in query
The code parameter obtained in the redirect.
grant_type
required string, in query
The grant type for the request. For initial authentication, must always be "authorization_code".

What am I missing ?

 

Thanks!

1 ACCEPTED SOLUTION

ActivityFix
Elbrus

Your error message says:

{"message":"Record Not Found","errors":[{"resource":"resource","field":"path","code":"invalid"}]}

Field: Path (the URL)
Code: Invalid

It's telling you that the URL you tried to use is invalid. If you look at Step 11 of the documentation you linked to and also copied in your message, you're using the wrong URL (path) to retrieve the token. It says to make a cURL request to

https://www.strava.com/oauth/token 

Compared to the code you posted

String authUrl = "https://www.strava.com/api/v3/oauth/token?" + <rest of your code>

The OAuth service is all under strava.com/oauth, it is separate from the API (at strava.com/api/v3).

View solution in original post

2 REPLIES 2

ActivityFix
Elbrus

Your error message says:

{"message":"Record Not Found","errors":[{"resource":"resource","field":"path","code":"invalid"}]}

Field: Path (the URL)
Code: Invalid

It's telling you that the URL you tried to use is invalid. If you look at Step 11 of the documentation you linked to and also copied in your message, you're using the wrong URL (path) to retrieve the token. It says to make a cURL request to

https://www.strava.com/oauth/token 

Compared to the code you posted

String authUrl = "https://www.strava.com/api/v3/oauth/token?" + <rest of your code>

The OAuth service is all under strava.com/oauth, it is separate from the API (at strava.com/api/v3).

Thank you !
Fast and helpful reply it now works !