chadhutchins/oauth2-suitecrm

SuiteCRM OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1.0.3 2021-09-23 16:15 UTC

This package is auto-updated.

Last update: 2024-10-23 23:08:27 UTC


README

Latest Stable Version Total Downloads License

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

Installation

To install, use composer:

composer require chadhutchins/oauth2-suitecrm

Usage

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

Authorization Code Flow

$provider = new \League\OAuth2\Client\Provider\GenericProvider([
    'clientId'                => 'SuiteCRM Client ID',    // The client ID assigned to you by the provider
    'clientSecret'            => 'SuiteCRM Client Secret',    // The client password assigned to you by the provider
    'redirectUri'             => 'https://my.example.com/your-redirect-url/',
    'urlAuthorize'            => 'https://your-suitecrm-instance.com/Api/authorize', // not used but still required by library
    'urlAccessToken'          => 'https://your-suitecrm-instance.com/Api/access_token',
    'urlResourceOwnerDetails' => 'https://your-suitecrm-instance/Api/V8/meta/modules',
]);

try {

    // Try to get an access token using the resource owner password credentials grant.
    $accessToken = $provider->getAccessToken('password', [
        'username' => 'suitecrm_username',
        'password' => 'suietcrm_password'
    ]);

} catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {

    // Failed to get the access token
    exit($e->getMessage());

}

Managing Scopes

SuiteCRM does not support scopes at this time. Limit access using ACL controls on the user you authenticate with.

Testing

$ ./vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

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