Authorization.java 文件源码

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

项目:SKIL_Examples 作者:
public String getAuthToken(String userId, String password) {
    String authToken = null;

    try {
        authToken =
                Unirest.post(MessageFormat.format("http://{0}:{1}/login", host, port))
                        .header("accept", "application/json")
                        .header("Content-Type", "application/json")
                        .body(new JSONObject() //Using this because the field functions couldn't get translated to an acceptable json
                                .put("userId", userId)
                                .put("password", password)
                                .toString())
                        .asJson()
                        .getBody().getObject().getString("token");
    } catch (UnirestException e) {
        e.printStackTrace();
    }

    return authToken;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号