olsgreen / oauth2-adobe-sign
为PHP League OAuth2-Client提供的Adobe Sign OAuth 2.0客户端提供程序
1.0.1
2021-12-02 22:53 UTC
Requires
- php: ^7.3 || ^8.0
- league/oauth2-client: ^2.0
Requires (Dev)
- mockery/mockery: ^1.3
- phpunit/phpunit: ^7.5.20 || ^9.3
This package is auto-updated.
Last update: 2024-09-23 01:18:27 UTC
README
本包为PHP League的OAuth 2.0客户端提供Adobe Sign OAuth 2.0支持。
寻找AdobeSign API客户端?请参阅olsgreen/adobe-sign-api。
本包需要PHP >= 7.3。
安装
要安装,请使用composer
composer require olsgreen/oauth2-adobe-sign
使用方法
使用方法与The League的OAuth客户端相同,使用\Olsgreen\OAuth2\Client\Provider\AdobeSign
作为提供程序。
授权码流
$provider = new Olsgreen\OAuth2\Client\Provider\AdobeSign([ 'clientId' => '{adobe-client-id}', 'clientSecret' => '{adobe-client-secret}', 'redirectUri' => 'https://example.com/callback-url', 'dataCenter' => 'eu2' ]); if (!isset($_GET['code'])) { $authorizationOptions = [ // See documentation relating to scopes: // https://opensource.adobe.com/acrobat-sign/developer_guide/helloworld.html#configure-scopes 'scope' => [ 'agreement_read', 'agreement_write', 'agreement_send', 'webhook_read', 'webhook_write', 'webhook_retention' ] ]; // If we don't have an authorization code then get one $authUrl = $provider->getAuthorizationUrl($authorizationOptions); $_SESSION['oauth2state'] = $provider->getState(); header('Location: '.$authUrl); exit; // Check given state against previously stored one to mitigate CSRF attack } elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) { unset($_SESSION['oauth2state']); exit('Invalid state'); } else { // Try to get an access token (using the authorization code grant) $token = $provider->getAccessToken('authorization_code', [ 'code' => $_GET['code'] ]); // Use this to interact with an API on the users behalf echo $token->getToken(); }
数据中心
数据中心应与您尝试访问的账户相同,因此最好将数据中心与访问令牌一起存储。当前的数据中心有:
- na1 = 北美1
- na2 = 北美2
- eu1 = 欧洲联盟1
- eu2 = 欧洲联盟2
- au1 = 澳大利亚1
- jp1 = 日本1
提供程序怪癖
Adobe不提供检索当前用户的端点,因此getResourceOwnerDetailsUrl()
、createResourceOwner()
和getResourceOwner()
将抛出NotImplmenetedException
。
测试
$ ./vendor/bin/phpunit
致谢
最初从kevinm/oauth2-adobe-sign分叉。
许可
MIT许可(MIT)。有关更多信息,请参阅许可文件。