안드로이드에서 가져온 access token을 이용해서 $.ajax 로 사용자 정보를 가져오려고 하는데요
관련된 예제나 방법등을 찾을수없습니다.
보통 facebook 같은경우는 REST API를 이용해서 사용자 정보를 읽어올수있는데요 parameter 가 body로 되어있어서 $.ajax로 요청이 가능한데 카카오톡은 header 에 parameter를 넣어야되서 REST API를 사용하지 못하고있습니다.
$.ajax({
headers: {‘Authorization’: ‘Bearer {accessToken}’},
type: ‘GET’,
url: ‘https://kapi.kakao.com/v1/user/me’,
async: false,
contentType: ‘application/x-www-form-urlencoded;charset=utf-8’,
…
알려주신 사이트 참고해서 이렇게 요청해봤습니다.
그런데
…
12-29 16:26:48.522: I/chromium(4864): [INFO:CONSOLE(0)] "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help, check http://xhr.spec.whatwg.org/.", source: (0)
12-29 16:26:48.525: D/libc-netbsd(4864): [getaddrinfo]: hostname=xxxxx; servname=(null); cache_mode=(null), netid=0; mark=0
12-29 16:26:48.525: D/libc-netbsd(4864): [getaddrinfo]: ai_addrlen=0; ai_canonname=xxxxx; ai_flags=1024; ai_family=2
12-29 16:26:48.802: I/chromium(4864): [INFO:CONSOLE(0)] “XMLHttpRequest cannot load https://kapi.kakao.com/v1/user/me. Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘https://aaa’ is therefore not allowed access. The response had HTTP status code 403.”, source: https://aaa.do (0)
…
403 에러가 발생합니다.
url이 잘못된것은 아닌데… 뭐가문제인지 모르겠네요…ㅜㅜ