forked from apilo-com/apilo-api-php
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExampleRefreshToken.php
More file actions
42 lines (33 loc) · 1.2 KB
/
Copy pathExampleRefreshToken.php
File metadata and controls
42 lines (33 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
use Apilo\Api\AuthorizationApi;
use Apilo\Configuration;
use Apilo\Model\RestAuthTokenPostRequest;
use Dotenv\Dotenv;
require_once(__DIR__ . '/../vendor/autoload.php');
require_once(__DIR__ . '/../../src/vendor/autoload.php');
loadEnv();
// Configure HTTP basic authorization: BasicAuth
$config = (new Configuration())
->setUsername(getenv('CLIENT_ID'))
->setPassword(getenv('CLIENT_SECRET'))
->setHost(getenv('HOST'))
;
$apiInstance = new AuthorizationApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(['verify' => false]),
$config
);
$payload = new RestAuthTokenPostRequest(); // \Apilo\Model\RestAuthTokenPostRequest
$payload->setGrantType(RestAuthTokenPostRequest::GRANT_TYPE_REFRESH_TOKEN);
$payload->setToken(getenv('REFRESH_TOKEN'));
try {
$result = $apiInstance->restAuthTokenPost($payload);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AuthorizationApi->restAuthTokenPost: ', $e->getMessage(), PHP_EOL;
}
function loadEnv(): void
{
(Dotenv::createUnsafeImmutable(__DIR__ . '/../'))->load();
}