diff --git a/src/GoHighLevel/Provider.php b/src/GoHighLevel/Provider.php index ab09e1518..763a3c4a5 100644 --- a/src/GoHighLevel/Provider.php +++ b/src/GoHighLevel/Provider.php @@ -15,11 +15,24 @@ class Provider extends AbstractProvider protected $scopes = ['users.readonly']; + protected bool $sameWindow = true; + protected function getAuthUrl($state): string { return $this->buildAuthUrlFromBase('https://marketplace.leadconnectorhq.com/oauth/chooselocation', $state); } + protected function getCodeFields($state = null) + { + $fields = parent::getCodeFields($state); + + if ($this->sameWindow) { + $fields['loginWindowOpenMode'] = 'self'; + } + + return $fields; + } + protected function getTokenUrl(): string { return 'https://services.leadconnectorhq.com/oauth/token'; @@ -39,7 +52,7 @@ protected function getUserByToken($token) $response = $this->getHttpClient()->get('https://services.leadconnectorhq.com/users/' . $userId, [ 'headers' => [ 'Authorization' => 'Bearer ' . $token, - 'Version' => '2021-07-28' + 'Version' => '2021-07-28', ], ]); @@ -87,4 +100,11 @@ public function refreshToken($refreshToken) return json_decode((string) $response->getBody(), true); } + + public function inSameWindow(bool $sameWindow = true): self + { + $this->sameWindow = $sameWindow; + + return $this; + } }