예제 #1
0
  /**
   * 获取access_token
   *
   * @param refreshToken
   * @return
   * @throws XueqiuException
   */
  public AccessToken getAccessTokenByRefreshToken(String refreshToken) throws XueqiuException {

    Map<String, String> params = new HashMap<String, String>();
    params.put("client_id", Config.getValue("client_id"));
    params.put("client_secret", Config.getValue("client_secret"));
    params.put("grant_type", "refresh_token");
    params.put("refresh_token", refreshToken);

    String json = HttpClientUtil.sendPost(Config.getValue("access_token_url"), params);

    return getAccessTokenFromJson(json);
  }
예제 #2
0
  /**
   * 获取access_token
   *
   * @param code
   * @return
   * @throws XueqiuException
   */
  public AccessToken getAccessTokenByCode(String code) throws XueqiuException {

    Map<String, String> params = new HashMap<String, String>();
    params.put("client_id", Config.getValue("client_id"));
    params.put("client_secret", Config.getValue("client_secret"));
    params.put("grant_type", "authorization_code");
    params.put("code", code);

    String json = HttpClientUtil.sendPost(Config.getValue("access_token_url"), params);

    return getAccessTokenFromJson(json);
  }