mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
fix: scopes
This commit is contained in:
parent
779510a605
commit
5d3071e084
1 changed files with 14 additions and 6 deletions
|
|
@ -20,10 +20,9 @@ class Slack extends OAuth2
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected array $scopes = [
|
protected array $scopes = [
|
||||||
'identity.avatar',
|
'openid',
|
||||||
'identity.basic',
|
'email',
|
||||||
'identity.email',
|
'profile',
|
||||||
'identity.team'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -42,7 +41,7 @@ class Slack extends OAuth2
|
||||||
// https://api.slack.com/authentication/oauth-v2
|
// https://api.slack.com/authentication/oauth-v2
|
||||||
return 'https://slack.com/oauth/v2/authorize?' . \http_build_query([
|
return 'https://slack.com/oauth/v2/authorize?' . \http_build_query([
|
||||||
'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
'scope' => \implode(',', $this->getScopes()),
|
'user_scope' => \implode(',', $this->getScopes()),
|
||||||
'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
'state' => \json_encode($this->state)
|
'state' => \json_encode($this->state)
|
||||||
]);
|
]);
|
||||||
|
|
@ -65,6 +64,10 @@ class Slack extends OAuth2
|
||||||
'redirect_uri' => $this->callback
|
'redirect_uri' => $this->callback
|
||||||
])
|
])
|
||||||
), true);
|
), true);
|
||||||
|
|
||||||
|
if (!$this->tokens['ok']) {
|
||||||
|
throw new \Exception('Error in fetching access token.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->tokens;
|
return $this->tokens;
|
||||||
|
|
@ -160,7 +163,12 @@ class Slack extends OAuth2
|
||||||
if (empty($this->user)) {
|
if (empty($this->user)) {
|
||||||
$user = $this->request(
|
$user = $this->request(
|
||||||
'GET',
|
'GET',
|
||||||
'https://slack.com/api/users.identity?token=' . \urlencode($accessToken)
|
'https://slack.com/api/users.identity',
|
||||||
|
[
|
||||||
|
'headers' => [
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken
|
||||||
|
]
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->user = \json_decode($user, true);
|
$this->user = \json_decode($user, true);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue