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\ProviderFactory()->new(
    clientId: '{fieldedge-client-id}',
    clientSecret: '{fieldedge-client-secret}',
);

// Get an access token
$token = $provider->getAccessToken('client_credentials', ['target_id' => 'my_target_id']);

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

$provider = new Compwright\OAuth2\FieldEdge\ProviderFactory()->newLegacy(
    clientId: '{fieldedge-client-id}',
    apiKey: '{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();