Skip to main content
Solved

Issue with OAuth authentication and request for documentation update


skvggor
Forum|alt.badge.img+3

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

Best answer by skvggor

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

 

View original
Did this topic help you find an answer to your question?

3 replies

Forum|alt.badge.img
  • Hub Starter
  • 1 reply
  • April 13, 2023

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" }


skvggor
Forum|alt.badge.img+3
  • Author
  • Hub Rookie
  • 1 reply
  • Answer
  • April 13, 2023

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

 


pascaldukers
Forum|alt.badge.img+3

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept, you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings