소셜로그인 채택완료

/html/plugin/social 과 테마스킨 외에도 social 로그인설정을 하는곳이있나요?

http://도메인/plugin/social/popup.php?provider=github

로 접속하면  Error:알수 없거나 비활성화 된 provider 입니다. 라는 애러가 발생하는데

g5_config 파일도 수정해주었고 관리자페이지에서 GitHub 사용도 체크했는데 어디를 또 수정해야되나요...

 

SocialLogin 관련 메뉴얼이나 자료는 없는건가요?

답변 3개

채택된 답변
+20 포인트

/html/plugin/social 에 모든 코어가 들어있습니다.

해당 파일들에 넣으셔야 할겁니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

/html/plugin/social/Hybrid/Providers 경로에 GitHub.php 파일을 생성하고
위의 답변글에있는 소스코드를 입력했습니다. 내용은 그누M 에있던 GitHub 파일이구요.
그리고 functions.php 의 social_extends_get_keys 함수에도 위의 답변의 Functions 코드를 입력했습니다. Database는 수정해두었구요. 그런데도 게속 로딩에 실패하네요..

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

- 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;

    }

}

 

- Functions : social_extends_get_keys 

Copy
$r['Github'] = array(

                    "enabled" => option_array_checked('github', $config['cf_social_servicelist']) ? true : false,

                    "keys" => array("id" => $config['cf_github_clientid'],

                    "secret" => $config['cf_github_secret']),

                    "redirect_uri" => get_social_callbackurl('github')

                    //"access_type"     => "offline",   // optional

                    //"approval_prompt" => "force",     // optional

                );
로그인 후 평가할 수 있습니다

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

메뉴얼들은 예를들면 카카오톡 로그인 API 검색하면 카카오톡 개발페이지에 명시되어있습니다

로그인 후 평가할 수 있습니다

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

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

로그인
🐛 버그신고