maybe someone could help me, I'm trying to get the refresh token issued after the first authorization of an Athlete with my application, the Oauth 2.0 works fine in postman and i can get the refresh token this way, but not in my persnoal php script ... I only got this kind of JSON response :
{
"token_type": "Bearer",
"access_token": "ACCESS_TOKEN",
"athlete": {
#{summary athlete representation}
}
}
But i'm waiting for a refresh token and a expiration date like the Strava API documentation demonstrate in this example:
{
"token_type": "Bearer",
"access_token": "987654321234567898765432123456789",
"athlete": {
#{summary athlete representation}
}
"refresh_token": "1234567898765432112345678987654321",
"expires_at": 1531378346,
"state": "STRAVA"
}
I've tryed to revoke access to the application from the test-account, to simulate a new auth request, many times, but i don't find the answer, here his my code to call the token exchange URL :
<?php
require 'config.php';
$code = $_GET['code'];
//The url you wish to send the POST request to
$url = "https://www.strava.com/oauth/token";
//The data you want to send via POST
$fields = [
'client_id' => $client_ID,
'client_secret' => $client_secret,
'code' => $code,
'grant_type' => 'authorization_code'
];
//url-ify the data for the POST
$fields_string = http_build_query($fields);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//So that curl_exec returns the contents of the cURL; rather than echoing it
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
//execute post
$result = curl_exec($ch);
echo $result;
print_r(curl_error($ch))
?>
PS : the Oauth 2.0 works fine in postman and i can get the refresh token this way, but not in my persnoal php script ...
Thx for helping.
https://www.strava.com/oauth/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&response_type=code&scope=YOUR_SCOPE
? – tezzoscope=read_all&scope=activity:read_all
, it works perfectly. – Maxime