PR review changes, add name from Podio
This commit is contained in:
parent
9623974ed5
commit
79cbdb537e
1 changed files with 15 additions and 8 deletions
|
@ -53,10 +53,8 @@ class Podio extends OAuth2
|
||||||
{
|
{
|
||||||
$url = $this->endpoint . '/authorize?' .
|
$url = $this->endpoint . '/authorize?' .
|
||||||
\http_build_query([
|
\http_build_query([
|
||||||
// 'response_type' => 'code',
|
|
||||||
'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
'state' => \json_encode($this->state),
|
'state' => \json_encode($this->state),
|
||||||
// 'scope' => \implode(' ', $this->getScopes()),
|
|
||||||
'redirect_uri' => $this->callback
|
'redirect_uri' => $this->callback
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -80,8 +78,7 @@ class Podio extends OAuth2
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
'client_secret' => $this->appSecret,
|
'client_secret' => $this->appSecret
|
||||||
// 'scope' => \implode(' ', $this->getScopes())
|
|
||||||
])
|
])
|
||||||
), true);
|
), true);
|
||||||
}
|
}
|
||||||
|
@ -168,7 +165,9 @@ class Podio extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getUserName(string $accessToken): string
|
public function getUserName(string $accessToken): string
|
||||||
{
|
{
|
||||||
return '';
|
$user = $this->getUser($accessToken);
|
||||||
|
|
||||||
|
return $user['name'] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,12 +178,20 @@ class Podio extends OAuth2
|
||||||
protected function getUser(string $accessToken): array
|
protected function getUser(string $accessToken): array
|
||||||
{
|
{
|
||||||
if (empty($this->user)) {
|
if (empty($this->user)) {
|
||||||
$user = $this->request(
|
$user = \json_decode($this->request(
|
||||||
'GET',
|
'GET',
|
||||||
$this->apiEndpoint . '/user',
|
$this->apiEndpoint . '/user',
|
||||||
['Authorization: Bearer ' . \urlencode($accessToken)]
|
['Authorization: Bearer ' . \urlencode($accessToken)]
|
||||||
);
|
), true);
|
||||||
$this->user = \json_decode($user, true);
|
|
||||||
|
$profile = \json_decode($this->request(
|
||||||
|
'GET',
|
||||||
|
$this->apiEndpoint . '/user/profile',
|
||||||
|
['Authorization: Bearer ' . \urlencode($accessToken)]
|
||||||
|
), true);
|
||||||
|
|
||||||
|
$this->user = $user;
|
||||||
|
$this->user['name'] = $profile['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->user;
|
return $this->user;
|
||||||
|
|
Loading…
Reference in a new issue