From 538f5cf1c3f33bafe4ab7f87796ec281bd180d0a Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sat, 18 Jan 2020 20:18:11 +0530 Subject: [PATCH] chore: github adapter changes --- src/Auth/OAuth/GitHub.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Auth/OAuth/GitHub.php b/src/Auth/OAuth/GitHub.php index 405f2f9f7..9eb0ca48f 100644 --- a/src/Auth/OAuth/GitHub.php +++ b/src/Auth/OAuth/GitHub.php @@ -11,6 +11,11 @@ class Github extends OAuth */ protected $user = []; + /** + * @var array + */ + protected $scopes = ['user:email']; + /** * @return string */ @@ -24,7 +29,13 @@ class Github extends OAuth */ public function getLoginURL():string { - return 'https://github.com/login/oauth/authorize?client_id='.urlencode($this->appID).'&redirect_uri='.urlencode($this->callback).'&scope=user:email&state='.urlencode(json_encode($this->state)); + return 'https://github.com/login/oauth/authorize?'. http_build_query([ + 'client_id' => $this->appID, + 'redirect_uri' => $this->callback, + 'scope' => implode(' ', $this->getScopes()), + 'state' => json_encode($this->state) + ]); + } /** @@ -38,10 +49,12 @@ class Github extends OAuth 'POST', 'https://github.com/login/oauth/access_token', [], - 'client_id='.urlencode($this->appID). - '&redirect_uri='.urlencode($this->callback). - '&client_secret='.urlencode($this->appSecret). - '&code='.urlencode($code) + http_build_query([ + 'client_id' => $this->appID, + 'redirect_uri' => $this->callback, + 'client_secret' => $this->appSecret, + 'code' => $code + ]) ); $output = [];