Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / auth / adapter / PhutilTwitchAuthAdapter.php
blobdce2c7e2f0c3b94a554598edd57202c5e2ed6960
1 <?php
3 /**
4 * Authentication adapter for Twitch.tv OAuth2.
5 */
6 final class PhutilTwitchAuthAdapter extends PhutilOAuthAuthAdapter {
8 public function getAdapterType() {
9 return 'twitch';
12 public function getAdapterDomain() {
13 return 'twitch.tv';
16 public function getAccountID() {
17 return $this->getOAuthAccountData('_id');
20 public function getAccountEmail() {
21 return $this->getOAuthAccountData('email');
24 public function getAccountName() {
25 return $this->getOAuthAccountData('name');
28 public function getAccountImageURI() {
29 return $this->getOAuthAccountData('logo');
32 public function getAccountURI() {
33 $name = $this->getAccountName();
34 if ($name) {
35 return 'http://www.twitch.tv/'.$name;
37 return null;
40 public function getAccountRealName() {
41 return $this->getOAuthAccountData('display_name');
44 protected function getAuthenticateBaseURI() {
45 return 'https://api.twitch.tv/kraken/oauth2/authorize';
48 protected function getTokenBaseURI() {
49 return 'https://api.twitch.tv/kraken/oauth2/token';
52 public function getScope() {
53 return 'user_read';
56 public function getExtraAuthenticateParameters() {
57 return array(
58 'response_type' => 'code',
62 public function getExtraTokenParameters() {
63 return array(
64 'grant_type' => 'authorization_code',
68 protected function loadOAuthAccountData() {
69 return id(new PhutilTwitchFuture())
70 ->setClientID($this->getClientID())
71 ->setAccessToken($this->getAccessToken())
72 ->setRawTwitchQuery('user')
73 ->resolve();