Path: blob/master/src/applications/auth/adapter/PhutilSlackAuthAdapter.php
12256 views
<?php12/**3* Authentication adapter for Slack OAuth2.4*/5final class PhutilSlackAuthAdapter extends PhutilOAuthAuthAdapter {67public function getAdapterType() {8return 'Slack';9}1011public function getAdapterDomain() {12return 'slack.com';13}1415public function getAccountID() {16$user = $this->getOAuthAccountData('user');17return idx($user, 'id');18}1920public function getAccountEmail() {21$user = $this->getOAuthAccountData('user');22return idx($user, 'email');23}2425public function getAccountImageURI() {26$user = $this->getOAuthAccountData('user');27return idx($user, 'image_512');28}2930public function getAccountRealName() {31$user = $this->getOAuthAccountData('user');32return idx($user, 'name');33}3435protected function getAuthenticateBaseURI() {36return 'https://slack.com/oauth/authorize';37}3839protected function getTokenBaseURI() {40return 'https://slack.com/api/oauth.access';41}4243public function getScope() {44return 'identity.basic,identity.team,identity.avatar';45}4647public function getExtraAuthenticateParameters() {48return array(49'response_type' => 'code',50);51}5253protected function loadOAuthAccountData() {54return id(new PhutilSlackFuture())55->setAccessToken($this->getAccessToken())56->setRawSlackQuery('users.identity')57->resolve();58}5960}616263