윈도우상에서 curl 실행시 에러

유저의 앱 연결해제 요청건으로 안드로이드 수정이 불가한 상황이라
현재 한명의 유저에 대해서 탈퇴처리를 위해 curl 를 사용하여 adminkey 와 id 를 호출했습니다.
아래와 같이 명령어를 날리고 실행하는데,
C:\Windows\System32> curl -v -X POST https://kapi.kakao.com/v1/user/unlink -H
“Authorization: KakaoAK 1fbf20bc305a2301b1ffbf757XXXXXXX” -d ‘target_id_type=us
er_id&target_id=80111XXX’

아래 이어서 메시지가 나오면서 실행에러가 뜨는것 같은데, 어떤 문제인가요?
adminkey 와 user_id 뒷부분은 여기서는 보안상 xxx 처리했습니다…
맨 아래 부분 메세지 상에는 no authentication key 라는데, 이 부분은
KakaoAK 1fbf20bc305a2301b1ffbf757XXXXXXX <= 이게 adminkey 가 안맞아서 그런것인지 …모르겠네요
adminkey 는

Note: Unnecessary use of -X or --request, POST is already inferred.

  • Trying 103.246.57.80…
  • Connected to kapi.kakao.com (103.246.57.80) port 443 (#0)
  • ALPN, offering h2
  • ALPN, offering http/1.1
  • Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
  • successfully set certificate verify locations:
  • CAfile: C:\Windows\System32\ca-bundle.crt
    CApath: none
  • TLSv1.2 (OUT), TLS header, Certificate Status (22):
  • TLSv1.2 (OUT), TLS handshake, Client hello (1):
  • TLSv1.2 (IN), TLS handshake, Server hello (2):
  • TLSv1.2 (IN), TLS handshake, Certificate (11):
  • TLSv1.2 (IN), TLS handshake, Server key exchange (12):
  • TLSv1.2 (IN), TLS handshake, Server finished (14):
  • TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
  • TLSv1.2 (OUT), TLS change cipher, Client hello (1):
  • TLSv1.2 (OUT), TLS handshake, Finished (20):
  • TLSv1.2 (IN), TLS change cipher, Client hello (1):
  • TLSv1.2 (IN), TLS handshake, Finished (20):
  • SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
  • ALPN, server did not agree to a protocol
  • Server certificate:
  • subject: C=KR; ST=Jeju-do; L=Jeju-si; O=Kakao Corp.; CN=*.kakao.com
  • start date: Nov 11 00:00:00 2015 GMT
  • expire date: Nov 10 23:59:59 2017 GMT
  • subjectAltName: host “kapi.kakao.com” matched cert’s “*.kakao.com”
  • issuer: C=US; O=thawte, Inc.; CN=thawte SSL CA - G2
  • SSL certificate verify ok.

POST /v1/user/unlink HTTP/1.1
Host: kapi.kakao.com
User-Agent: curl/7.48.0
Accept: /
Authorization: KakaoAK 1fbf20bc305a2301b1ffbf757xxxxx
Content-Length: 23
Content-Type: application/x-www-form-urlencoded

  • upload completely sent off: 23 out of 23 bytes
    < HTTP/1.1 401 Unauthorized
    < Date: Thu, 31 Mar 2016 07:02:12 GMT
    < Server: Apache
    < WWW-Authenticate: KakaoAK
    < Content-Type: application/json;charset=UTF-8
    < Content-Length: 44
    <
    {“code”:-401,“msg”:“no authentication key!”}* Connection #0 to host kapi.kakao.c
    om left intact

개인쪽지 보내드렸어요~ 확인해주세요! :smiley:

확인해보니, Authorization 헤더로 KakaoAK [app의 admin key] 로 요청하셔야 하는데, native app key를 사용하셨네요.
Authorization 헤더로 KakaoAK 를 보내실 땐 언제나 admin key 를 사용해주세요~! :smile:

자세한 사항은 https://developers.kakao.com/docs/restapi#사용자-관리-앱-연결-해제 를 참고하시면 됩니다.

참고로 window에서는 curl을 single quote로 하면 안된다네요~
다음 링크 참고하세요~
http://stackoverflow.com/questions/2783827/running-curl-cmd-from-win7-doesnt-work-but-on-linux-it-does

고맙습니다~
우선 admin 키를 사용했어야 했고,
curl -v -X POST https://kapi.kakao.com/v1/user/unlink -H “Authorization: KakaoAK ef136593597bbddb69f5cd1xxxxxxxxxxxxx” -d “target_id_type=user_id” -d “target_id=8011xxxxx”

위에 처럼
target_id_type 과 target_ID 를 각각 -d 옵션으로 적어줘야 하고, 각 파라미터를 따로 구분해서 써야 하네요 ^^

음… admin 키를 사용하시는 건 맞는데요, target_id_type과 targe_id를 구분하지 않으셔도 될 것 같아요~
해당 문제는 윈도우 curl 이용시 홑따옴표로 요청해서 요청이 잘못 들어간 것이었습니다.
홑따옴표가 아닌 쌍따옴표를 이용하여 다음과 같이 요청해도 될 거에요~

-d "target_id=user_id&target_id=8011xxxxx"

아 그렇군요! 저렇게 해보니 탈퇴가 되길래…^^
고맙습니다!!

1개의 좋아요