| @@ 695-707 (lines=13) @@ | ||
| 692 | * @param string $grant_type Default sets to 'client_credentials' |
|
| 693 | * @throws RequestException |
|
| 694 | */ |
|
| 695 | private function auth($grant_type = 'client_credentials'): void |
|
| 696 | { |
|
| 697 | //TODO: Add auth for username and password |
|
| 698 | $body = [ |
|
| 699 | 'grant_type' => $grant_type, |
|
| 700 | 'client_secret' => $this->client_secret, |
|
| 701 | 'client_id' => $this->client_id |
|
| 702 | ]; |
|
| 703 | ||
| 704 | $response = Http::asForm()->post($this->login_url, $body)->throw()->json(); |
|
| 705 | $this->token = $response['access_token']; |
|
| 706 | $this->token_expiry = now()->addSeconds($response['expires_in'])->unix(); |
|
| 707 | } |
|
| 708 | } |
|
| 709 | ||
| @@ 115-129 (lines=15) @@ | ||
| 112 | /** |
|
| 113 | * @return void |
|
| 114 | */ |
|
| 115 | private function auth(): void |
|
| 116 | { |
|
| 117 | $this->setClientCredentials(); |
|
| 118 | ||
| 119 | //TODO: Add auth for username and password |
|
| 120 | $body = [ |
|
| 121 | 'grant_type' => $this->grantType, |
|
| 122 | 'client_secret' => $this->clientSecret, |
|
| 123 | 'client_id' => $this->clientId |
|
| 124 | ]; |
|
| 125 | ||
| 126 | $response = Http::asForm()->post($this->loginUrl, $body)->throw()->json(); |
|
| 127 | $this->token = $response['access_token']; |
|
| 128 | $this->tokenExpiry = now()->addSeconds($response['expires_in'])->unix(); |
|
| 129 | } |
|
| 130 | } |
|
| 131 | ||