killmails/oauth2-eve
Composer 安装命令:
composer require killmails/oauth2-eve
包简介
EVE Online OAuth 2.0 Client Provider for The PHP League OAuth2-Client
README 文档
README
This package provides EVE Online OAuth 2.0 support for the PHP League's OAuth 2.0 Client.
Installation
To install, use composer:
composer require killmails/oauth2-eve:^2.0
Usage
Usage is the same as The League's OAuth client, using \Killmails\OAuth2\Client\Provider\EveOnline as the provider.
Authorization Code Flow
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()); }
Managing Scopes
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.
Testing
composer test
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 629
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-04