yf_oauth_driver_github class

Fileplugins/oauth/classes/oauth/yf_oauth_driver_github.class.php
Use_class('oauth_driver_github', 'classes/oauth/')
Extendsyf_oauth_driver2

Public properties

A site sets them in its config with $PROJECT_CONF['oauth_driver_github']['NAME'] = ...;

PropertyDefaultDescription
$get_access_token_method 'POST'
$scope 'user'

Public methods 2

get_user_info

public function get_user_info()
    public function get_user_info()
    {
        $access_token = $this->_storage_get('access_token');
        if ( ! $access_token) {
            $access_token = $this->get_access_token();
            if ( ! $access_token) {
                $this->_storage_clean();
                js_redirect($this->redirect_uri, $url_rewrite = false);
                return false;
            }
        }
        if ( ! $this->_storage_get('user')) {
            $url = $this->url_user . '?' . http_build_query([
                'access_token' => $access_token,
            ]);
            $opts = null;
            $response = null;
            $result = common()->get_remote_page($url, $cache = false, $opts, $response);
            $result = $this->_decode_result($result, $response, __FUNCTION__);
            if (isset($result['error']) || substr($response['http_code'], 0, 1) == '4') {
                $this->_storage_clean();
                js_redirect($this->redirect_uri, $url_rewrite = false);
                return false;
            }
            $this->_storage_set('user_info_request', ['result' => $result, 'response' => $response]);
            $user = $result;

            // Emails
            $url_emails = $this->url_user_emails . '?' . http_build_query([
                    'access_token' => $access_token,
                ]);
            $result = common()->get_remote_page($url_emails, $cache = false, $opts = [], $response);
            $result = $this->_decode_result($result, $response, __FUNCTION__);
            $user['emails'] = $result;

            $this->_storage_set('user', $user);
        }
        return $this->_storage_get('user');
    }

Methods starting with _ hooks and helpers; not routable as page actions

public function _get_user_info_for_auth($raw = [])
    public function _get_user_info_for_auth($raw = [])
    {
        $user_info = [
            'user_id' => $raw['id'],
            'login' => $raw['login'],
            'name' => $raw['login'],
            'email' => current($raw['emails']),
            'avatar_url' => $raw['avatar_url'],
            'profile_url' => $raw['html_url'],
        ];
        return $user_info;
    }

Inherited methods

from yf_oauth_driver2: _decode_result(), _storage_clean(), _storage_get(), _storage_set(), authorize(), get_access_token(), login()