카카오 로그인 API 엑세스 토큰 문의

결과값 = {“error”:“invalid_client”,“error_description”:“Bad client credentials”,“error_code”:“KOE010”}

body = {“code”:“2kMkdCqhXWTZ8GM7qLl22wUG-ajsBzLeP_H8kQD5yeL38_n6vQFg7zHxzpnCQLoZXovlzgopb1QAAAGEwlpa6Q”,“redirect_uri”:“https://cknet-7c-dev-ed.develop.lightning.force.com/kakaocallback",“client_id”:“59551d5b44e9edb9590945997540ee1c”,“grant_type”:"authorization_code”}

endpoint = ‘https://kauth.kakao.com/oauth/token

method = ‘post’

header = ‘content-type’, ‘application/x-www-form-urlencoded;charset=utf-8’

위에 값으로 설정하고 보냈는데 결과값이 저렇게 나왔습니다…
잘못된 정보가 있을까요 ??

구현 코드 전체를 공유해 주시겠어요?

String address = ‘https://kauth.kakao.com/oauth/token’;
Http http = new Http();
HttpRequest req = new HttpRequest();
String headerValue;

Map<String, Object> reqParams = new Map<String, Object>();
reqParams.put(‘grant_type’, ‘authorization_code’);
reqParams.put(‘client_id’, ‘59551d5b44e9edb9590945997540ee1c’);
reqParams.put(‘client_secret’, ‘tN70HXwdvV4qe6RsKEBDvGenZeNEmJ6s’);
reqParams.put(‘redirect_uri’, ‘https://cknet-7c-dev-ed.develop.lightning.force.com/kakaocallback’);
reqParams.put(‘code’, ‘2RfKiLrektePXZDBBUKZMhUX_NwRAfta5vevMjn4ezcSWAWwIXmEC0w8RT1tEMEx7KZ_GAo9dZsAAAGExlw8RQ’);
headerValue = JSON.serialize(reqParams);

req.setMethod(‘POST’);
req.setEndpoint(address);
req.setHeader(‘content-type’, ‘application/x-www-form-urlencoded;charset=utf-8’);
req.setBody(headerValue);

HttpResponse response = new HTTPResponse();
response = http.send(req);
System.debug(response.getBody());

이렇게 코드를 구현하였습니다.

접근토큰 발급은 application/x-www-form-urlencoded 형태로 보내야 합니다.
JsonString 이 아닌 QueryString 유형으로 호출해보시겠어요?

https://kauth.kakao.com/oauth/token?grant_type=authorization_code&client_id=59551d5b44e9edb9590945997540ee1c&redirect_uri=https://cknet-7c-dev-ed.develop.lightning.force.com/kakaocallback&code=2RfKiLrektePXZDBBUKZMhUX_NwRAfta5vevMjn4ezcSWAWwIXmEC0w8RT1tEMEx7KZ_GAo9dZsAAAGExlw8RQ

body를 이런식으로 하라는 말씀이신가요??