Skip to main content

Hello Strava team,


I hope this message finds you well. My name is Marcos and I have recently been experiencing difficulties while using the Strava API, specifically with the OAuth authentication process. The code I have been using up until now is as follows:


curl -X POST https://www.strava.com/api/v3/oauth/token
-d client_id=ReplaceWithClientID
-d client_secret=ReplaceWithClientSecret
-d grant_type=refresh_token
-d refresh_token=ReplaceWithRefreshToken


Unfortunately, it seems that this code is no longer working and I am having trouble obtaining the code parameter required for some requests. Furthermore, after checking the documentation page, I noticed that the information does not appear to be up-to-date.


I would like to request your assistance in resolving this issue and, if possible, ask for an update to the documentation. This would be extremely helpful for me and other developers who use the Strava API.


Thank you in advance for your attention and I eagerly await your guidance.


Best regards,


Marcos

looks like I have the same problem
Sometimes when I try to refresh my access token I get a 400 error

responce
{ "resource": "RefreshToken", "field": "refresh_token", "code": "invalid" }


Hey there! I managed to finally solve the problem using this generic request:

Pseudocode:

FUNCTION getEnvVar(key)
// Retrieve the environment variable for the given key

FUNCTION getRequestData
RETURN {
client_id: getEnvVar("client_id"),
client_secret: getEnvVar("client_secret"),
refresh_token: getEnvVar("refresh_token"),
grant_type: "refresh_token"
}

FUNCTION getAccessToken
url = getEnvVar("strava_domain") + "/api/v3/oauth/token"
headers = {
"Content-Type": "application/json"
}
response = postRequest(url, jsonEncode(getRequestData()), headers)
RETURN response

I used this pseudocode to represent the logic without specifying the language. It should be easily understandable for someone familiar with any programming language.

Example working: https://github.com/skvggor/strava-api-wrapper-clojure

 


Thank you for sharing a solution. Unfortunately I can only give you one kudo.


Reply