깃허브 소셜로그인 오류? 채택완료

깃허브 소셜로그인을 했을때 세션에 access_token 이 저장될때도 있고 저장이 안될때도 있습니다.

저장이 될때는 HA::STORE 에 저장이되는데 이마저도 access_token 만 저장이되고 나머지

refresh_token, expires_in, expires_at 은 저장이 안됩니다.

로그인을 성공했으면 이제 access_token 을 가지고 다른 API 들을 호출해야되는데 저장이 안되네요...

그리고 관리자는 소셜로그인을 연동해도 access_token이 세션에 저장되지않게 되어있나요?

 

- /html/plugin/social/Hybrid/Providers/Github.php

Copy
<?php

/*!

* HybridAuth

* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth

*  (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html

*/

 

/**

 * Hybrid_Providers_GitHub

 */

class Hybrid_Providers_GitHub extends Hybrid_Provider_Model_OAuth2

{

    // default permissions

    // (no scope) => public read-only access (includes public user profile info, public repo info, and gists).

    public $scope = "user";

 

    /**

    * IDp wrappers initializer

    */

    function initialize()

    {

        parent::initialize();

 

        // Provider api end-points

        $this->api->api_base_url  = "https://api.github.com/";

        $this->api->authorize_url = "https://github.com/login/oauth/authorize";

        $this->api->token_url     = "https://github.com/login/oauth/access_token";

    }

 

    /**

    * load the user profile from the IDp api client

    */

    function getUserProfile()

    {

        $data = $this->api->api( "user" );

 

        if ( ! isset( $data->id ) ){

            throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );

        }

 

        $this->user->profile->identifier  = @ $data->id;

        $this->user->profile->displayName = @ $data->name;

        $this->user->profile->description = @ $data->bio;

        $this->user->profile->photoURL    = @ $data->avatar_url;

        $this->user->profile->profileURL  = @ $data->html_url;

        $this->user->profile->email       = @ $data->email;

        $this->user->profile->webSiteURL  = @ $data->blog;

        $this->user->profile->region      = @ $data->location;

 

        if( empty($this->user->profile->displayName) ){

            $this->user->profile->displayName = @ $data->login;

        }

 

        // request user emails from github api

        if( empty($data->email) ){

            try{

                $emails = $this->api->api("user/emails");

 

                // fail gracefully, and let apps collect the email if not present

                if (is_array($emails)) {

                    foreach ($emails as $email) {

                        if ($email instanceof stdClass

                            && property_exists($email, 'primary')

                            && true === $email->primary

                            && property_exists($email, 'email')

                        ) {

                            $this->user->profile->email = $email->email;

 

                            // record whether the email address is verified

                            if (property_exists($email, 'verified')

                                && true === $email->verified

                            ) {

                                $this->user->profile->emailVerified = $email->email;

                            }

 

                            break;

                        }

                    }

                }

            }

            catch( GithubApiException $e ){

                throw new Exception( "User email request failed! {$this->providerId} returned an error: $e", 6 );

            }

        }

 

        $this->user->profile->sid = get_social_convert_id( $this->user->profile->identifier, $this->providerId );

 

        return $this->user->profile;

    }

    /**

    *

    */

    function getUserContacts() {

        // refresh tokens if needed

        $this->refreshToken();

 

        //

        $response = array();

        $contacts = array();

        try {

            $response = $this->api->api( "user/followers" );

        } catch (Exception $e) {

            throw new Exception("User contacts request failed! {$this->providerId} returned an error: $e");

        }

        //

        if ( isset( $response ) ) {

            foreach ($response as $contact) {

                try {

                    $contactInfo = $this->api->api( "users/".$contact->login );

                } catch (Exception $e) {

                    throw new Exception("Contact info request failed for user {$contact->login}! {$this->providerId} returned an error: $e");

                }

                //

                $uc = new Hybrid_User_Contact();

                //

                $uc->identifier     = $contact->id;

                $uc->profileURL     = @$contact->html_url;

                $uc->webSiteURL     = @$contact->blog;

                $uc->photoURL       = @$contact->avatar_url;

                $uc->displayName    = ( isset( $contactInfo->name )?( $contactInfo->name ):( $contact->login ) );

                //$uc->description  = ;

                $uc->email          = @$contactInfo->email;

                //

                $contacts[] = $uc;

            }

        }

        return $contacts;

    }

}

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고