teltek / oauth2-oracle-access-manager
PHP League OAuth2-Client 的 Oracle Access Manager OAuth 2.0 客户端提供程序
1.0.3
2021-02-01 12:07 UTC
Requires
- php: >=5.5.9
- league/oauth2-client: 2.2.0
- pumukit/pumukit: <=2.7
Requires (Dev)
- phpunit/phpunit: ~4.5
This package is auto-updated.
Last update: 2024-08-29 04:31:18 UTC
README
此包已弃用,仅适用于 PuMuKIT v2.7 或更低版本。
要使用 PuMuKIT v3 或更高版本,请安装新包: PumukitOAuth2Bundle
OAuth 2.0 客户端提供程序
此包为 PHP League 的 OAuth 2.0 客户端 提供Oracle Access Manager OAuth 2.0 支持。
安装
安装时请使用 composer
composer require teltek/oauth2-oracle-access-manager
使用方法
使用方法与 The League 的 OAuth 客户端相同,使用 Teltek\Oauth2OracleAccessManagerBundle\Provider\Oam
作为提供程序。
授权码流程
$provider = new Teltek\Oauth2OracleAccessManagerBundle\Provider\Oam( 'clientId' => 'your client id', 'clientSecret' => 'your client secret', 'redirectUri' => 'your redirect uri', 'urlAuthorize' => 'your url authorize', 'urlAccessToken' => 'your url access token', 'urlResourceOwnerDetails' => 'your url resource owner details', ]); if (!isset($_GET['code'])) { $options['scope'] = array('Customer.Info','UserProfile.me'); $authorizationUrl = $provider->getAuthorizationUrl($options); $_SESSION['oauth2state'] = $provider->getState(); header('Location: '.$authorizationUrl); exit; } elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) { unset($_SESSION['oauth2state']); exit('Invalid state'); } else { try { $accessToken = $provider->getAccessToken('authorization_code',['code' => $_GET['code']]); $resourceOwner = $provider->getResourceOwner($accessToken); ... } catch (IdentityProviderException $e) { exit($e->getMessage()); }
作用域
如果您想发送不同的作用域,您必须编辑
$options['scope'] = array('Customer.Info','UserProfile.me');