This package provides EVE Online OAuth 2.0 support for the PHP League's OAuth 2.0 Client.
To install, use composer:
composer require killmails/oauth2-eve:^2.0
Usage is the same as The League's OAuth client, using \Killmails\OAuth2\Client\Provider\EveOnline
as the provider.
use Killmails\OAuth2\Client\Provider\EveOnline;
$sso = new EveOnline([
'clientId' => '{eveonline-client-id}',
'clientSecret' => '{eveonline-client-secret}',
'redirectUri' => 'https://example.com/callback-url',
]);
if (empty($_GET['code'])) {
$url = $sso->getAuthorizationUrl();
$_SESSION['state'] = $sso->getState();
header('Location: '.$authUrl);
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['state'])) {
unset($_SESSION['state']);
} else {
$token = $sso->getAccessToken('authorization_code', [
'code' => $_GET['code']
]);
$user = $sso->getResourceOwner($token);
printf('Hello, %s (%d)', $user->getName(), $user->getId());
}
When creating your EVE Online authorization URL, you can specify the state and scopes your application may authorize.
$options = [
'scope' => ['esi-killmails.read_killmails.v1']
];
$url = $sso->getAuthorizationUrl($options);
// ...
If neither are defined, the provider will utilize internal defaults.
composer test
The MIT License (MIT). Please see License File for more information.