From a4630b499569c7c5aa840b28ce85d7078ed5b4f9 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sun, 19 Jan 2020 01:18:59 +0530 Subject: [PATCH] chpore: vk adapter changes --- src/Auth/OAuth/Vk.php | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Auth/OAuth/Vk.php b/src/Auth/OAuth/Vk.php index ad860aff8..2fbc9f9b6 100644 --- a/src/Auth/OAuth/Vk.php +++ b/src/Auth/OAuth/Vk.php @@ -17,6 +17,11 @@ class Vk extends OAuth */ protected $user = []; + /** + * @var array + */ + protected $scopes = ['openid' ,'email']; + /** * @var string */ @@ -36,13 +41,14 @@ class Vk extends OAuth */ public function getLoginURL(): string { - return 'https://oauth.vk.com/authorize?' . - 'client_id='.urlencode($this->appID). - '&redirect_uri='.urlencode($this->callback). - '&response_type=code'. - '&state='.urlencode(json_encode($this->state)). - '&v='.urlencode($this->version). - '&scope=openid+email'; + return 'https://oauth.vk.com/authorize?' . http_build_query([ + 'client_id' => $this->appID, + 'redirect_uri' => $this->callback, + 'response_type' => 'code', + 'state' => json_encode($this->state), + 'v' => $this->version, + 'scope' => implode(' ', $this->getScopes()) + ]); } /** @@ -57,10 +63,12 @@ class Vk extends OAuth 'POST', 'https://oauth.vk.com/access_token?', $headers, - 'code=' . urlencode($code) . - '&client_id=' . urlencode($this->appID) . - '&client_secret=' . urlencode($this->appSecret). - '&redirect_uri='.urlencode($this->callback) + http_build_query([ + 'code' => $code, + 'client_id' => $this->appID, + 'client_secret' => $this->appSecret, + 'redirect_uri' => $this->callback + ]) ); $accessToken = json_decode($accessToken, true);