【问题标题】:API Manager OAuth Token Revoke is ProblematicAPI Manager OAuth 令牌撤销有问题
【发布时间】:2014-04-21 17:15:48
【问题描述】:

我正在使用 SAML2 Bearer 断言配置文件从 WSO2 API Manager 获取 OAuth 令牌。我有两个客户端应用程序。在 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。这里出了什么问题?

【问题讨论】:

    标签: wso2 wso2is


    【解决方案1】:

    API Manager 默认启用缓存并设置为 15 分钟。尝试禁用它。

    【讨论】:

    • 我认为这解决了问题!感谢您的帮助!
    猜你喜欢
    • 2017-06-20
    • 1970-01-01
    • 2015-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-06
    • 2018-09-09
    • 1970-01-01
    相关资源
    最近更新 更多