<?php

use HMRC\Oauth2\Provider;

require_once __DIR__.'/../vendor/autoload.php';
require_once __DIR__.'/../helpers.php';

session_start();

$provider = new Provider(
    'K7Urzs7EpjA2Cz_WA5UCstQE3r4a',
    '0eee5320-2c70-4757-bc65-22dd65fab0ec',
    'https://daso-id.com/vat/oauth2/callback.php'
);

// Try to get an access token using the authorization code grant.
$accessToken = $provider->getAccessToken('authorization_code', [
    'code' => $_GET['code'],
]);

\HMRC\Oauth2\AccessToken::set($accessToken);

header('Location: /vat/index.php');
exit;
