contactduty/oauth-contact-duty

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

Installs: 22

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/contactduty/oauth-contact-duty

0.0.5 2018-11-06 21:05 UTC

This package is auto-updated.

Last update: 2025-10-07 17:33:51 UTC


README

ContactDuty OAuth 2.0 support for the PHP League’s OAuth 2.0 Client.

Installation

$ composer require contactduty/oauth-contact-duty

Usage

You can get your OAuth client credentials here.

try {
    $provider = new ContactDuty\OAuth2\Client([
        'clientId'          => $clientId,
        'clientSecret'      => $clientSecret,
        'redirectUri'       => $redirectUri
    ]);

    $accessToken = $provider->getAccessToken('client_credentials');
    
    echo 'Access Token: ' . $accessToken->getToken() . "<br>";
    echo 'Expired in: ' . $accessToken->getExpires() . "<br>";
    echo 'Already expired? -> ' . ($accessToken->hasExpired() ? 'expired' : 'not expired') . "<br>";
    
 } catch (League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
    // Failed to get the access token
    die($e->getMessage());
}