The Hub is now in read-only mode as we make improvements to the Hub experience. More information is available here.
04-07-2023 04:24 AM - last edited on 07-06-2023 04:42 PM by LouB
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
Solved! Go to Solution.
04-13-2023 06:41 AM
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
04-13-2023 06:41 AM
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
04-21-2023 09:06 AM
Thank you for sharing a solution. Unfortunately I can only give you one kudo.
04-13-2023 01:20 AM - edited 04-13-2023 01:31 AM
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" }
Welcome to the Community - here is your guide to help you get started!