PHP code example of creode / business-central-oauth2
1. Go to this page and download the library: Download creode/business-central-oauth2 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/ */
creode / business-central-oauth2 example snippets
use Creode\BusinessCentralOauth2\Providers\BusinessCentralProvider;
$provider = new BusinessCentralProvider([
'clientId' => 'your-client-id',
'clientSecret' => 'your-client-secret',
'redirectUri' => 'your-redirect-uri',
'urlAccessToken' => 'your-token-url',
]);
$accessToken = $provider->getAccessToken('client_credentials', [
'scope' => 'your-scope',
]);
$request = $provider->getAuthenticatedRequest(
'GET',
'https://api.businesscentral.dynamics.com/v2.0/{tenantId}/{environmentName}/',
$accessToken
);
$response = $provider->getParsedResponse($request);