@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at recaptime-dev/main 61 lines 1.4 kB view raw
1<?php 2 3/** 4 * Authentication adapter for Slack OAuth2. 5 */ 6final class PhutilSlackAuthAdapter extends PhutilOAuthAuthAdapter { 7 8 public function getAdapterType() { 9 return 'Slack'; 10 } 11 12 public function getAdapterDomain() { 13 return 'slack.com'; 14 } 15 16 public function getAccountID() { 17 $user = $this->getOAuthAccountData('user'); 18 return idx($user, 'id'); 19 } 20 21 public function getAccountEmail() { 22 $user = $this->getOAuthAccountData('user'); 23 return idx($user, 'email'); 24 } 25 26 public function getAccountImageURI() { 27 $user = $this->getOAuthAccountData('user'); 28 return idx($user, 'image_512'); 29 } 30 31 public function getAccountRealName() { 32 $user = $this->getOAuthAccountData('user'); 33 return idx($user, 'name'); 34 } 35 36 protected function getAuthenticateBaseURI() { 37 return 'https://slack.com/oauth/authorize'; 38 } 39 40 protected function getTokenBaseURI() { 41 return 'https://slack.com/api/oauth.access'; 42 } 43 44 public function getScope() { 45 return 'identity.basic,identity.team,identity.avatar'; 46 } 47 48 public function getExtraAuthenticateParameters() { 49 return array( 50 'response_type' => 'code', 51 ); 52 } 53 54 protected function loadOAuthAccountData() { 55 return id(new PhutilSlackFuture()) 56 ->setAccessToken($this->getAccessToken()) 57 ->setRawSlackQuery('users.identity') 58 ->resolve(); 59 } 60 61}