Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathExampleRefreshToken.php
More file actions
Latest commit
43 lines (34 loc) · 1.23 KB
/
Copy pathExampleRefreshToken.php
File metadata and controls
43 lines (34 loc) · 1.23 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
43
<?php
useApilo\Api\AuthorizationApi;
useApilo\Configuration;
useApilo\Model\AuthorizationRequest;
useApilo\Model\RestAuthTokenPostRequest;
useDotenv\Dotenv;
require_once(__DIR__ . '/../vendor/autoload.php');
require_once(__DIR__ . '/../../src/vendor/autoload.php');
loadEnv();
// Configure HTTP basic authorization: BasicAuth
$config = (newConfiguration())
->setUsername(getenv('CLIENT_ID'))
->setPassword(getenv('CLIENT_SECRET'))
->setHost(getenv('HOST'))
;
$apiInstance = newAuthorizationApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
newGuzzleHttp\Client(['verify' => false]),
$config
);
$payload = newAuthorizationRequest(); // \Apilo\Model\RestAuthTokenPostRequest
$payload->setGrantType(RestAuthTokenPostRequest::GRANT_TYPE_REFRESH_TOKEN);
$payload->setToken(getenv('REFRESH_TOKEN'));
try {
$result = $apiInstance->postRestAuthTokenpost($payload);
print_r($result);
} catch (Exception$e) {
echo'Exception when calling AuthorizationApi->restAuthTokenPost: ', $e->getMessage(), PHP_EOL;
}
functionloadEnv(): void
{
(Dotenv::createUnsafeImmutable(__DIR__ . '/../'))->load();
}