Path: blob/master/src/applications/auth/adapter/PhutilTwitchAuthAdapter.php
12256 views
<?php12/**3* Authentication adapter for Twitch.tv OAuth2.4*/5final class PhutilTwitchAuthAdapter extends PhutilOAuthAuthAdapter {67public function getAdapterType() {8return 'twitch';9}1011public function getAdapterDomain() {12return 'twitch.tv';13}1415public function getAccountID() {16return $this->getOAuthAccountData('_id');17}1819public function getAccountEmail() {20return $this->getOAuthAccountData('email');21}2223public function getAccountName() {24return $this->getOAuthAccountData('name');25}2627public function getAccountImageURI() {28return $this->getOAuthAccountData('logo');29}3031public function getAccountURI() {32$name = $this->getAccountName();33if ($name) {34return 'http://www.twitch.tv/'.$name;35}36return null;37}3839public function getAccountRealName() {40return $this->getOAuthAccountData('display_name');41}4243protected function getAuthenticateBaseURI() {44return 'https://api.twitch.tv/kraken/oauth2/authorize';45}4647protected function getTokenBaseURI() {48return 'https://api.twitch.tv/kraken/oauth2/token';49}5051public function getScope() {52return 'user_read';53}5455public function getExtraAuthenticateParameters() {56return array(57'response_type' => 'code',58);59}6061public function getExtraTokenParameters() {62return array(63'grant_type' => 'authorization_code',64);65}6667protected function loadOAuthAccountData() {68return id(new PhutilTwitchFuture())69->setClientID($this->getClientID())70->setAccessToken($this->getAccessToken())71->setRawTwitchQuery('user')72->resolve();73}7475}767778