/** * Post a form with parameters * @param url Url as string * @param params map with parameters/values * @return response Response as string * @throws IOException */ public static String postForm(String url, Map<String, String> params) throws IOException { return postForm(url, params, null); }
private ObjectNode exchangeCodeForAuthorization(String code) throws IOException { Map<String, String> params = new HashMap<String, String>(); params.put("code", code); params.put("client_id", CLIENT_ID); params.put("client_secret", CLIENT_SECRET); params.put("redirect_uri", REDIRECT_URI); params.put("grant_type", "authorization_code"); String res = HttpUtil.postForm(OAUTH_URI + "/token", params); ObjectNode json = mapper.readValue(res, ObjectNode.class); return json; }
params.put("refresh_token", refresh_token); params.put("grant_type", "refresh_token"); String resp = HttpUtil.postForm(OAUTH_URI + "/token", params); ObjectNode json = JOM.getInstance().readValue(resp, ObjectNode.class); if (!json.has("access_token")) {
params.put("refresh_token", refresh_token); params.put("grant_type", "refresh_token"); String resp = HttpUtil.postForm(OAUTH_URI + "/token", params); ObjectNode json = JOM.getInstance().readValue(resp, ObjectNode.class); if (!json.has("access_token")) {