Skip to main content

I would sometimes get an error when calling the token exchange API: POST https://www.strava.com/oauth/token, but it would work if I make the exact same call for a second attempt. Anyone know why this is happening?

 

In the “authenticaion” documentation on Strava Developers, one statement says the URL should be https://www.strava.com/oauth/token, while an example shows the URL as https://www.strava.com/api/v3/oauth/token (I pasted below)

 

Is this why my call to the API returns an error sometimes?

 

Thanks.

===================================================

Token Exchange

Strava will respond to the authorization request by redirecting the user agent to the redirect_uri provided.

If access is denied, error=access_denied will be included in the query string.

If access is accepted, code and scope parameters will be included in the query string. The code parameter contains the authorization code required to complete the authentication process. code is short lived and can only be used once. The application must now call the POST https://www.strava.com/oauth/token with its client ID and client secret to exchange the authorization code for a refresh token and short-lived access token.

The state parameter will be always included in the response if it was initially provided by the application.

 

Request Parameters
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".

 

Example cURL Request

curl -X POST https://www.strava.com/api/v3/oauth/token \
-d client_id=ReplaceWithClientID \
-d client_secret=ReplaceWithClientSecret \
-d code=ReplaceWithCode \
-d grant_type=authorization_code

Hi ​@elvinpedro, while I don't have an answer, let me ask a clarifying question - what specific error (error code) are you getting? Some of the local API experts might be able to help you based on that. Thanks!


Reply