RocketChatClientCallBuilder.java 文件源码

java
阅读 20 收藏 0 点赞 0 评论 0

项目:rocket-chat-rest-client 作者:
private void login() throws IOException {
    HttpResponse<JsonNode> loginResult;

    try {
        loginResult = Unirest.post(serverUrl + "v1/login").field("username", user).field("password", password).asJson();
    } catch (UnirestException e) {
        throw new IOException(e);
    }

    if (loginResult.getStatus() == 401)
        throw new IOException("The username and password provided are incorrect.");

    if (loginResult.getStatus() != 200)
        throw new IOException("The login failed with a result of: " + loginResult.getStatus());

    JSONObject data = loginResult.getBody().getObject().getJSONObject("data");
    this.authToken = data.getString("authToken");
    this.userId = data.getString("userId");
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号