PHP code example of teltek / oauth2-oracle-access-manager

1. Go to this page and download the library: Download teltek/oauth2-oracle-access-manager library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

teltek / oauth2-oracle-access-manager example snippets


$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');