앱 id 1012404
토큰 발급 시 Server returned HTTP response code: 401 for URL: https://kauth.kakao.com/oauth/token
java.lang.RuntimeException: 카카오 토큰 요청 중 오류가 발생했습니다.
에러가 발생합니다. Client Secret은 비활성화 상태입니다.
public String getToken(String code) throws IOException {
try {
String access_Token = "";
final String reqURL = "https://kauth.kakao.com/oauth/token";
URL url = new URL(reqURL);
HttpURLConnection urlCon = (HttpURLConnection) url.openConnection();
urlCon.setRequestMethod("POST");
urlCon.setDoOutput(true);
try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(urlCon.getOutputStream()))) {
StringBuilder sb = new StringBuilder();
sb.append("grant_type=authorization_code");
sb.append("client_id=REST API 키");
sb.append("&redirect_uri=Redirect URI");
sb.append("&code=" + code);
bw.write(sb.toString());
bw.flush();
bw.close();
}