dev-master
9999999-devHuman OAuth 2.0 support for the PHP League's OAuth 2.0 Client
MIT
The Requires
- php >=5.5.0
- league/oauth2-client ~1.0@dev
The Development Requires
by Indika Gunasekara
authentication authorization oauth client oauth2 human
Wallogit.com
2017 © Pedro Peláez
Human OAuth 2.0 support for the PHP League's OAuth 2.0 Client
This package provides Human OAuth 2.0 support for the PHP League's OAuth 2.0 Client., (*2)
$provider = new \Human\OAuth2\Client\Provider\Human([
'clientId' => 'XXXXXXXX',
'clientSecret' => 'XXXXXXXX',
'redirectUri' => 'https://your-registered-redirect-uri/',
'account' => 'XXXXX'
]);
if (!isset($_GET['code'])) {
$authurl = $provider->getAuthorizationUrl();
$_SESSION['oauth2state'] = $provider->getState();
header('Location: '.$authUrl);
exit;
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])){
unset($_SESSION['oauth2state']);
exit('Invalid state');
} else {
$token = $provider->getAccessToken('authorization_code', [
'code' => $_GET['code']
]);
try {
$client = new Client($token);
$user = $client->getResourceOwner();
echo $user->getFirstName();
} catch (Exception $e) {
echo "Oops!..."
}
}
The MIT License (MIT). Please see License File for more information., (*3)
Human OAuth 2.0 support for the PHP League's OAuth 2.0 Client
MIT
authentication authorization oauth client oauth2 human