UserInformationService.java 文件源码

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

项目:wso2is-example 作者:
/**
 * 
 * @param accessToken
 * @return JSON with user info
 * @throws IOException
 */
public String getUserInformation(String accessToken) throws IOException {
    String endpoint = AuthProperties.inst().getUserInformationEndpoint();

    URL url = new URL(endpoint);
    HttpURLConnection con = (HttpURLConnection) url.openConnection();

    String authorizationHeader = String.format("Bearer %s", accessToken);
    con.addRequestProperty("Authorization", authorizationHeader);

    con.setRequestMethod("GET");
    con.connect();

    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String inputLine;
    StringBuffer response = new StringBuffer();

    while ((inputLine = in.readLine()) != null) {
        response.append(inputLine);
    }

    in.close();

    return response.toString();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号