카카오톡 소셜 로그인 에러 문제

안녕하세요.
일반적인 워드프레스 플러그인 문제도 혹시 문의가 가능한지 싶어 글을 남깁니다.

만일 답변이 가능하시면 부탁드리겠습니다.

현재 

  1. 문제가 재현되는 site 의 url 은 http://www.ohlady.co.kr

  2. 소셜 설치 플러그인 : Wordpress Social Plugins

      3.네이버 ,카카오 소셜 설치 : WordPress Social Login extends NAVE

      4. https://github.com/usefulparadigm/hybridauth-kakao 사용했습니다.

      5. 저같은 경우 직접 functions.php 에 추가를 하지 않고 WordPress Social Login extends NAVER 통해 Wordpress Social Plugins 에등록을 해서 API 값을 넣고 진행을 했었습니다.

      6. 처음 로그인시 동의 묻는 부분을 거쳐 로그인을 진행하고 나서 부터 계속 로그인명이 없는 상태로는 사용자를 생성할 수 없습니다라는 에러가 뜨는 문제입니다.

       로그인 에러 화면

       제일 처음에는 http://www.usefulparadigm.com/2014/07/15/adding-kakao-login-to-wordpress/ 를 통해서 하다가 이미지가 계속 먹지가 않아서 그냥 플러그인을 통해서 설치를 해서 테마내 functions.php 부분은 따로 손댄것은 없습니다.

     

       코스모스팜 로그인을 할때 카카오톡으로 로그인을 할 수 있게 되어 있어서 혹시나 해서 문의 드렸습니다.

       참고로 지금 셋팅한 kakao.php 소스 내용입니다.

---------------------------------------------------------------------------------------------------------------------------

 

/*!
* HybridAuth
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
*  (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
*/

/**
 * Hybrid_Providers_Kakao 
 */
class Hybrid_Providers_Kakao extends Hybrid_Provider_Model_OAuth2

    /**
    * IDp wrappers initializer 
    */
    function initialize() 
    {
        parent::initialize();

        // Provider api end-points
        $this->api->api_base_url  = "https://kapi.kakao.com/v1/";
        $this->api->authorize_url = "https://kauth.kakao.com/oauth/authorize";
        $this->api->token_url     = "https://kauth.kakao.com/oauth/token";
    }

    /**
    * finish login step 
    */
    function loginFinish()
    {
        $error = (array_key_exists('error',$_REQUEST))?$_REQUEST['error']:"";

        // check for errors
        if ( $error ){ 
            throw new Exception( "Authentication failed! {$this->providerId} returned an error: $error", 5 );
        }

        // try to authenicate user
        $code = (array_key_exists('code',$_REQUEST))?$_REQUEST['code']:"";

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

        // check if authenticated
        if ( ! $this->api->access_token ){ 
            throw new Exception( "Authentication failed! {$this->providerId} returned an invalid access token.", 5 );
        }

        // store tokens
        $this->token( "access_token" , $this->api->access_token  );
        $this->token( "refresh_token", $this->api->refresh_token );
        $this->token( "expires_in"   , $this->api->access_token_expires_in );
        $this->token( "expires_at"   , $this->api->access_token_expires_at );

        // set user connected locally
        $this->setUserConnected();
    }

    /**
    * load the user profile from the IDp api client
    */
    function getUserProfile()
    {
        // ask kakao api for user infos
        $this->user->profile->email = "kakao_user".$kakao_user_id."@example.com";  --> 기존 소스에 동일한 문제가 있는 내용을 검색해서 이 문구로 해결이 되었다고 추가를 했는데도 여전히 에러가 나오네요.
        $data = $this->api->api( "user/me" ); 
        
        if ( ! isset( $data->id ) || isset( $data->error ) ){
            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->properties->nickname;
        $this->user->profile->photoURL    = @ $data->properties->thumbnail_image;

        return $this->user->profile;
    }

    private function authenticate( $code )
    {
        $params = array(
            "client_id"     => $this->api->client_id,
            "grant_type"    => "authorization_code",
            "redirect_uri"  => $this->api->redirect_uri,
            "code"          => $code
        );
        
        $response = $this->request( $this->api->token_url, $params, $this->api->curl_authenticate_method );

        $response = $this->parseRequestResult( $response );

        if( ! $response || ! isset( $response->access_token ) ){
            throw new Exception( "The Authorization Service has return: " . $response->error );
        }

        if( isset( $response->access_token  ) )  $this->api->access_token           = $response->access_token;
        if( isset( $response->refresh_token ) ) $this->api->refresh_token           = $response->refresh_token; 
        if( isset( $response->expires_in    ) ) $this->api->access_token_expires_in = $response->expires_in; 
        
        // calculate when the access token expire
        if( isset($response->expires_in)) {
            $this->api->access_token_expires_at = time() + $response->expires_in;
        }

        return $response;  
    }

    private function request( $url, $params=false, $type="GET" )
    {
    // Hybrid_Logger::info( "Enter OAuth2Client::request( $url )" );
    // Hybrid_Logger::debug( "OAuth2Client::request(). dump request params: ", serialize( $params ) );

        $this->http_info = array();
        $ch = curl_init();
        
        curl_setopt($ch, CURLOPT_URL            , $url );
        curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1 );
        curl_setopt($ch, CURLOPT_TIMEOUT        , $this->api->curl_time_out );
        curl_setopt($ch, CURLOPT_USERAGENT      , $this->api->curl_useragent );
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , $this->api->curl_connect_time_out );
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , $this->api->curl_ssl_verifypeer );
        curl_setopt($ch, CURLOPT_HTTPHEADER     , $this->api->curl_header );

        if($this->api->curl_proxy){
            curl_setopt( $ch, CURLOPT_PROXY        , $this->curl_proxy);
        }

        if( $type == "POST" ){
            curl_setopt($ch, CURLOPT_POST, 1); 
            if($params) curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($params) );
        }

        $response = curl_exec($ch);
    // Hybrid_Logger::debug( "OAuth2Client::request(). dump request info: ", serialize( curl_getinfo($ch) ) );
    // Hybrid_Logger::debug( "OAuth2Client::request(). dump request result: ", serialize( $response ) );

        $this->http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $this->http_info = array_merge($this->http_info, curl_getinfo($ch));

        curl_close ($ch);

        return $response; 
    }

    private function parseRequestResult( $result )
    {
        if( json_decode( $result ) ) return json_decode( $result );

        parse_str( $result, $ouput ); 

        $result = new StdClass();

        foreach( $ouput as $k => $v )
            $result->$k = $v;

        return $result;
    }
}

 

좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
워드프레스 에러 기술지원 서비스 전문가에게 맡기세요