Closed zcampaner closed 6 years ago
Hoping to get fast feedback and help as I am in the midst of a deadline :(
Assuming $this->client_id
, $this->client_secret
and $code
are valid then try:
$results = $api->tokenExchange($code);
$api->setAccessToken($results->access_token);
$code
should be in the URL that Strava redirects you back to as part of the Oauth handshake. I use something like:
$code = $_GET['code']; // Or $code = filter_input(INPUT_GET, 'code', FILTER_SANITIZE_STRING);
I still got the same errors
object(stdClass)#21 (2) { ["message"]=> string(19) "Authorization Error" ["errors"]=> array(1) { [0]=> object(stdClass)#22 (3) { ["resource"]=> string(11) "Application" ["field"]=> string(0) "" ["code"]=> string(7) "invalid" } }
If you do a var_dump()
for:
$this->client_id
$this->client_secret
$code
$api
$results
Are they all set and valid?
@zcampaner did you manage to get this working? So sorry, I didn't spot this issue earlier.
From the looks of the error, it might be that the $code
you're passing to $api->tokenExchange($code);
is not valid. Are you going through the process of generating the authentication URL and coming back to the redirect page with the ?code
param populated before making the token exchange?
@adriangibbons thanks a lot for helping. Really appreciate it 👍
Closing due to inactivity.
I am getting this kind of errror
stdClass::__set_state(array( 'message' => 'Authorization Error', 'errors' => array ( 0 => stdClass::__set_state(array( 'resource' => 'Application', 'field' => '', 'code' => 'invalid', )), ), ))
And this is my script
`$api = new Iamstuartwilson\StravaApi( $this->client_id, $this->client_secret ); $redirect = 'http://www.onlineraces.ph/app/Admin/auth_login';