PHP code example of compwright / oauth2-fieldedge

1. Go to this page and download the library: Download compwright/oauth2-fieldedge 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/ */

    

compwright / oauth2-fieldedge example snippets


$provider = new Compwright\OAuth2_Fieldedge\Provider([
    'clientId'      => '{fieldedge-client-id}',
    'clientSecret'  => '{fieldedge-api-key}',
]);

// Get an access token
$token = $provider->getAccessToken('client_credentials');

// Use the token to interact with an API on the users behalf
echo $token->getToken();

// The token is really a JWT, getResourceOwnerId() extracts the company_id claim
echo $token->getResourceOwnerId();