chore: gitlab adapter fixes

This commit is contained in:
Christy Jacob 2020-01-18 20:38:46 +05:30
parent 538f5cf1c3
commit d2a19207c2

View file

@ -14,6 +14,11 @@ class Gitlab extends OAuth
*/ */
protected $user = []; protected $user = [];
/**
* @var array
*/
protected $scopes = ['read_user'];
/** /**
* @return string * @return string
*/ */
@ -27,12 +32,13 @@ class Gitlab extends OAuth
*/ */
public function getLoginURL(): string public function getLoginURL(): string
{ {
return 'https://gitlab.com/oauth/authorize?'. return 'https://gitlab.com/oauth/authorize?'.http_build_query([
'client_id='.urlencode($this->appID). 'client_id' => $this->appID,
'&redirect_uri='.urlencode($this->callback). 'redirect_uri' => $this->callback,
'&scope=read_user'. 'scope' => implode(' ', $this->getScopes()),
'&state='.urlencode(json_encode($this->state)). 'state' => json_encode($this->state),
'&response_type=code'; 'response_type' => 'code'
]);
} }
/** /**
@ -44,12 +50,13 @@ class Gitlab extends OAuth
{ {
$accessToken = $this->request( $accessToken = $this->request(
'POST', 'POST',
'https://gitlab.com/oauth/token?'. 'https://gitlab.com/oauth/token?'.http_build_query([
'code='.urlencode($code). 'code' => $code,
'&client_id='.urlencode($this->appID). 'client_id' => $this->appID,
'&client_secret='.urlencode($this->appSecret). 'client_secret' => $this->appSecret,
'&redirect_uri='.urlencode($this->callback). 'redirect_uri' => $this->callback,
'&grant_type=authorization_code' 'grant_type' => 'authorization_code'
])
); );
$accessToken = json_decode($accessToken, true); $accessToken = json_decode($accessToken, true);