0
WSO2 API 관리자에서 OAuth 토큰을 얻기 위해 SAML2 무기명 인증 프로필을 사용하고 있습니다. 두 가지 클라이언트 응용 프로그램이 있습니다. OAuth Token Revoke 프로세스에서 다음 코드를 사용 중입니다.API 관리자 OAuth 토큰 폐기가 문제가 발생했습니다.
public static boolean revokeToken(Token token) throws IOException {
//Create connection to the Token endpoint of API manger
URL url = new URL(Config.apiMangerOAuthRevokeURL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
String userCredentials = Config.apiMangerClientID+":"+ Config.apiMangerClientSecret;
String basicAuth = "Basic " + new String(Base64.encodeBytes(userCredentials.getBytes()));
basicAuth = basicAuth.replaceAll("\\r|\\n", "");
// Set the consumer-key and Consumer-secret
connection.setRequestProperty("Authorization", basicAuth);
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
//Send request
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes("token="+token.getAccess_token());
wr.flush();
wr.close();
//Get Response
InputStream iss = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(iss));
String line;
StringBuffer responseString = new StringBuffer();
while ((line = rd.readLine()) != null) {
responseString.append(line);
responseString.append('\r');
}
rd.close();
System.out.println("Revoking Token Mobile-"+token.getAccess_token());
System.out.println("Revoking Response Mobile -"+responseString.toString());
return true
;
}
하나의 클라이언트 응용 프로그램이 취소 프로세스를 수행합니다. 취소 후 CURL을 사용하여 API를 호출하려고했으나 예상대로 실패합니다. 그러나 위와 같은 논리를 사용하여 토큰을 취소하는 다른 클라이언트 응용 프로그램은 올바르게 반환됩니다. 그러나 토큰은 해지 한 후에 유효합니다. CURL을 사용하여 API를 쿼리 할 수 있습니다. 여기서 무엇이 잘못 되었습니까?
이 문제가 해결 된 것 같습니다. 도와 주셔서 감사합니다! – andunslg