Gnuboard(Google)에서 소셜 로그인 연결을 끊습니다.

카카오, 네이버에 이어 그누보드에서 구글 소셜 로그인 바로가기를 비활성화하는 방법에 대해 알아보겠습니다.

2023-03-08 – (개발) – 그누보드(카카오)와 소셜로그인 분리

gnuboard(카카오)에서 소셜 로그인 해제

그누보드에서 소셜로그인 적용 테스트시 회원탈퇴시 소셜로그인 바로가기를 비활성화 해야하는데 데이터베이스에서 삭제되는데 바로가기가 해제가 안되네요…

swmaster.tistory.com

제 이전 글을 읽으셨다면,

www/plugin/social/includes/functions.php 파일에서,

social_member_link_delete 함수에서 데이터베이스의 소셜 계정 정보를 삭제한 후 unlink 함수를 호출하는 부분이 있습니다.

1. Google.php에서 연결 해제 기능 만들기

다음과 같이 www/plugin/social/Hybrid/Providers/Google.php 파일에 연결 해제 기능을 만듭니다.

  function unlink($code)
  {

    $params = array(
        "grant_type"    => "authorization_code",
        "client_id"     => $this->api->client_id,
        "client_secret" => $this->api->client_secret,
        "token"         => $this->api->access_token,
        "code"          => $code
    );

    $revokeURL = "https://oauth2.googleapis.com/revoke?token=".$this->api->access_token;

    $http_info = array();

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $revokeURL);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
    $response = curl_exec($ch); //run

    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get HTTP code

    curl_close($ch);

    if ($httpCode == 200)
    {
      echo "<script>alert('$httpCode => Success');</script>";
      return "Success";
    }
    else
      return "Fail";
  }

카카오, 네이버와 달리 구글 소셜로그인은 별도의 요청 기능이 없습니다.

그래서 curl 관련 함수를 직접 적용해서 사용했습니다.

Google 소셜 로그인 연결을 해제하는 주요 핵심 포인트는 revokeURL입니다.

$revokeURL = ” https://oauth2.googleapis.com/revoke?token= “.$this->api->access_token;

URL에 access_token 값을 보내고 매개변수에 client_id / client_secret / token / code를 포함합니다.

2. 결과 확인

Google은 별도의 동의 확인창을 표시하지 않았습니다.

신규 등록에도 동일하게 적용됩니다.

그러나 위의 소스처럼 curl을 실행한 후 httpCode가 200이면 성공이라고 합니다.


Gnuboard(Google)에서 소셜 로그인 연결을 끊습니다. 1

연결을 해제할 때 $httpCode가 200이면 메시지가 throw되지만 성공적으로 throw됩니다.

위에서 우리는 Gnuboard에서 Google 소셜 로그인을 비활성화하는 기능을 추가하는 방법을 배웠습니다.