Path: blob/master/src/applications/auth/adapter/PhutilWordPressAuthAdapter.php
12256 views
<?php12/**3* Authentication adapter for WordPress.com OAuth2.4*/5final class PhutilWordPressAuthAdapter extends PhutilOAuthAuthAdapter {67public function getAdapterType() {8return 'wordpress';9}1011public function getAdapterDomain() {12return 'wordpress.com';13}1415public function getAccountID() {16return $this->getOAuthAccountData('ID');17}1819public function getAccountEmail() {20return $this->getOAuthAccountData('email');21}2223public function getAccountName() {24return $this->getOAuthAccountData('username');25}2627public function getAccountImageURI() {28return $this->getOAuthAccountData('avatar_URL');29}3031public function getAccountURI() {32return $this->getOAuthAccountData('profile_URL');33}3435public function getAccountRealName() {36return $this->getOAuthAccountData('display_name');37}3839protected function getAuthenticateBaseURI() {40return 'https://public-api.wordpress.com/oauth2/authorize';41}4243protected function getTokenBaseURI() {44return 'https://public-api.wordpress.com/oauth2/token';45}4647public function getScope() {48return 'user_read';49}5051public function getExtraAuthenticateParameters() {52return array(53'response_type' => 'code',54'blog_id' => 0,55);56}5758public function getExtraTokenParameters() {59return array(60'grant_type' => 'authorization_code',61);62}6364protected function loadOAuthAccountData() {65return id(new PhutilWordPressFuture())66->setClientID($this->getClientID())67->setAccessToken($this->getAccessToken())68->setRawWordPressQuery('/me/')69->resolve();70}7172}737475