rmartignoni / oauth2-strava
Strava OAuth2 Client
dev-master
2016-04-05 18:15 UTC
Requires
- league/oauth2-client: 1.3.0
Requires (Dev)
- phpunit/phpunit: 4.8.24
This package is not auto-updated.
Last update: 2025-01-04 21:19:29 UTC
README
Strava OAuth2 Client
$client = new \rmartignoni\OAuth2\Strava\Client\Provider\Strava([ 'clientId' => '[your_client_id]', 'clientSecret' => '[your_client_secret]', 'redirectUri' => '[redirect_uri]', ], []); if (!isset($_GET['code'])) { $authorizationUrl = $client->getAuthorizationUrl(['approval_prompt' => 'force']); $_SESSION['oauth2state'] = $client->getState(); header('Location:' . $authorizationUrl); exit; } if (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) { unset($_SESSION['oauth2state']); throw new \Exception; } $accessToken = $client->getAccessToken('authorization_code', [ 'code' => $_GET['code'], ]); echo $accessToken->getToken();