olsgreen/oauth2-adobe-sign

Adobe Sign OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1.0.1 2021-12-02 22:53 UTC

This package is auto-updated.

Last update: 2024-04-23 00:34:08 UTC


README

Latest Version Tests Software License

This package provides Adobe Sign OAuth 2.0 support for the PHP League's OAuth 2.0 Client.

Looking for an AdobeSign API client? See olsgreen/adobe-sign-api.

This package requires PHP >= 7.3.

Installation

To install, use composer:

composer require olsgreen/oauth2-adobe-sign

Usage

Usage is the same as The League's OAuth client, using \Olsgreen\OAuth2\Client\Provider\AdobeSign as the provider.

Authorization Code Flow

$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();
}

Data Centers

The data center should match that of the account you are trying to access, so best store the datacenter with the access token. The current datacenters are:

  • na1 = North America 1
  • na2 = North America 2
  • eu1 = EU 1
  • eu2 = EU 2
  • au1 = Australia 1
  • jp1 = Japan 1

Provider Quirks

Adobe do not provide an endpoint to retrieve the current user, so getResourceOwnerDetailsUrl(), createResourceOwner() & getResourceOwner() will throw NotImplmenetedException.

Testing

$ ./vendor/bin/phpunit

Credits

Originally forked from kevinm/oauth2-adobe-sign.

License

The MIT License (MIT). Please see License File for more information.