|
1 | 1 | <?php |
2 | 2 |
|
3 | | - require 'vendor/autoload.php'; |
| 3 | +require 'vendor/autoload.php'; |
4 | 4 |
|
5 | | - use GuzzleHttp\Client; |
| 5 | +use GuzzleHttp\Client; |
6 | 6 |
|
7 | | - $clientId = 'Client Id from https://dashboard.aspose.cloud/applications'; |
8 | | - $clientSecret = 'Client Secret from https://dashboard.aspose.cloud/applications'; |
| 7 | +$clientId = 'Client Id from https://dashboard.aspose.cloud/applications'; |
| 8 | +$clientSecret = 'Client Secret from https://dashboard.aspose.cloud/applications'; |
9 | 9 |
|
10 | | - // Check the client_id is changed to not break GitHub CI pipeline |
11 | | - if (str_starts_with($clientId, "Client Id")) { |
12 | | - echo "clientId not configured. Skip this snippet test"; |
13 | | - return; |
14 | | - } |
| 10 | +// Check the client_id is changed to not break GitHub CI pipeline |
| 11 | +if (str_starts_with($clientId, "Client Id")) { |
| 12 | + echo "clientId not configured. Skip this snippet test"; |
| 13 | + return; |
| 14 | +} |
15 | 15 |
|
16 | | - $url = 'https://id.aspose.cloud/connect/token'; |
| 16 | +$url = 'https://id.aspose.cloud/connect/token'; |
17 | 17 |
|
18 | | - $data = [ |
19 | | - 'grant_type' => 'client_credentials', |
20 | | - 'client_id' => $clientId, |
21 | | - 'client_secret' => $clientSecret |
22 | | - ]; |
| 18 | +$data = [ |
| 19 | + 'grant_type' => 'client_credentials', |
| 20 | + 'client_id' => $clientId, |
| 21 | + 'client_secret' => $clientSecret |
| 22 | +]; |
23 | 23 |
|
24 | | - $client = new Client(); |
| 24 | +$client = new Client(); |
25 | 25 |
|
26 | | - $response = $client->post($url, [ |
27 | | - 'form_params' => $data, |
28 | | - 'headers' => [ |
29 | | - 'Content-Type' => 'application/x-www-form-urlencoded' |
30 | | - ] |
31 | | - ]); |
| 26 | +$response = $client->post($url, [ |
| 27 | + 'form_params' => $data, |
| 28 | + 'headers' => [ |
| 29 | + 'Content-Type' => 'application/x-www-form-urlencoded' |
| 30 | + ] |
| 31 | +]); |
32 | 32 |
|
33 | | - $body = $response->getBody()->getContents(); |
34 | | - $statusCode = $response->getStatusCode(); |
| 33 | +$body = $response->getBody()->getContents(); |
| 34 | +$statusCode = $response->getStatusCode(); |
35 | 35 |
|
36 | | - if ($statusCode >= 200 && $statusCode < 300) { |
37 | | - $bodyArray=json_decode($body, true); |
38 | | - $token=$bodyArray["access_token"]; |
39 | | - echo "Token recieved successfully\n"; |
40 | | - // To veiw token uncomment next line |
41 | | - // echo "$token"; |
| 36 | +if ($statusCode >= 200 && $statusCode < 300) { |
| 37 | + $bodyArray=json_decode($body, true); |
| 38 | + $token=$bodyArray["access_token"]; |
| 39 | + echo "Token recieved successfully\n"; |
| 40 | + // To veiw token uncomment next line |
| 41 | + // echo "$token"; |
42 | 42 |
|
43 | | - } else { |
44 | | - throw new Exception("Unexpected HTTP code: $statusCode\nResponse: $body\n"); |
45 | | - } |
| 43 | +} else { |
| 44 | + throw new Exception("Unexpected HTTP code: $statusCode\nResponse: $body\n"); |
| 45 | +} |
0 commit comments