카카오로그인 연동 실패 msg":"no authentication key!","code":-401

안녕하세요. 카카오로그인 연동 문의 드립니다.
아이디,비밀번호 입력하는 로그인페이지는 잘 뜨는데,로그인 후 리다이렉트되는 부분에서 문제가 있는거같습니다…
헌데 뭐가 문제인지 못찾겠네요… 에러코드가

Error1 = {“msg”:“no authentication key!”,“code”:-401}

인증키값을 받아오지 못한다 하는데… 어떻게 해결을 해야할까요 ;

리다이렉트페이지 http://lmhst.cafe24.com/
입니다…

$returnCode = $_GET[“code”]; //발급받은 code 값

$callbackURI = urlencode("/shop/kakaoRedirectForm.php");

$restAPIKey = “”;

$returnUrl = “https://kauth.kakao.com/oauth/token?grant_type=authorization_code&client_id=".$restAPIKey."&redirect_uri=".$callbackURI."&code=”.$returnCode;

$isPost = false;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $returnUrl);

curl_setopt($ch, CURLOPT_POST, $isPost);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$headers = array();

$response = curl_exec ($ch);

$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);

if($status_code == 200){

$result = json_decode($response);

$token = $result->access_token;

$header = "Bearer".$token;

$url = "https://kapi.kakao.com/v2/user/me";

$is_post = false;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_POST, $is_post);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

//$headers = array();

$headers[] = "Authorization: ".$header;

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec ($ch);

$_info_status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);

echo "code=".$_info_status_code."<br>";

echo "response=".$response."<br>";

if($_info_status_code == 200){

    $_kakao = json_decode($response);

    $data = array();

    $data['id'] = 'kakao_'.$_kakao->id;

    $data['email'] = $_kakao->kakao_account->email;    

}else{

    echo "Error1 = ".$response;

}

}else{

echo "Error2 = ".$response;

}

안녕하세요.

Bearer 뒤에 공백 한칸 추가 해보시겠어요?

$header = "Bearer ".$token;

헤더에 Authorization는 아래와 같은 형태여야 하거든요.

Authorization: Bearer 토큰값

1개의 좋아요

아…감사합니다 오전 근 두시간정도 이것때문에 헤메이고있었는데,ㅠㅠ 감사합니다

1개의 좋아요