PHP code example of helpscout / oauth2-hubspot

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

    

helpscout / oauth2-hubspot example snippets


$provider = new HelpScout\OAuth2\Client\Provider\HubSpot([
    'clientId'          => '{hubspot-client-id}',
    'clientSecret'      => '{hubspot-client-secret}',
    'redirectUri'       => 'https://example.com/callback-url'
]);

$provider = new HelpScout\OAuth2\Client\Provider\HubSpot([
    'clientId'          => '{hubspot-client-id}',
    'clientSecret'      => '{hubspot-client-secret}',
    'redirectUri'       => 'https://example.com/callback-url'
]);

$existingAccessToken = getAccessTokenFromYourDataStore();

if ($existingAccessToken->hasExpired()) {
    $newAccessToken = $provider->getAccessToken('refresh_token', [
        'refresh_token' => $existingAccessToken->getRefreshToken()
    ]);

    // Purge old access token and store new access token to your data store.
}