Skip to content

Commit

Permalink
fix: GHL return Token with refresh (#1330)
Browse files Browse the repository at this point in the history
  • Loading branch information
atymic authored Feb 2, 2025
1 parent 8e6aead commit d0590aa
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/GoHighLevel/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use GuzzleHttp\RequestOptions;
use Illuminate\Support\Arr;
use Laravel\Socialite\Two\Token;
use SocialiteProviders\Manager\OAuth2\AbstractProvider;
use SocialiteProviders\Manager\OAuth2\User;

Expand Down Expand Up @@ -82,7 +83,7 @@ protected function mapUserToObject(array $user)
*
* @param string $refreshToken
*
* @return array
* @return Token
*/
public function refreshToken($refreshToken)
{
Expand All @@ -98,7 +99,14 @@ public function refreshToken($refreshToken)
],
]);

return json_decode((string) $response->getBody(), true);
$token = json_decode((string) $response->getBody(), true, 512, JSON_THROW_ON_ERROR);

return new Token(
Arr::get($token, 'access_token'),
Arr::get($token, 'refresh_token'),
Arr::get($token, 'expires_in'),
explode($this->scopeSeparator, Arr::get($token, 'scope', ''))
);
}

public function inSameWindow(bool $sameWindow = true): self
Expand Down

0 comments on commit d0590aa

Please # to comment.