示例#1
0
  /**
   * This method is used to generate a session id for user based authentication. A session id is
   * required in order to use any of the write methods.
   *
   * @param token The authentication token
   * @return The authenticated session ID
   * @throws TMDbResponseException Throws whether the server response is not a success.
   */
  public static String getNewSession(TMDbToken token) throws TMDbResponseException {

    TMDbResponseObject response = TMDbAPI.getAuthenticationSession(token);

    if (response.hasError()) {
      throw new TMDbResponseException(response.getStatus());
    } else {
      return new String(response.getData().getString(TMDbConstants.SESSION_ID));
    }
  }
示例#2
0
  /**
   * This method is used to generate a valid request token for user based authentication. A request
   * token is required in order to request a session id. You can generate any number of request
   * tokens but they will expire after 60 minutes. As soon as a valid session id has been created
   * the token will be destroyed.
   *
   * @return The authentication token
   * @throws TMDbResponseException Throws whether the server response is not a success.
   */
  public static TMDbToken getNewToken() throws TMDbResponseException {

    TMDbResponseObject response = TMDbAPI.getAuthenticationToken();

    if (response.hasError()) {
      throw new TMDbResponseException(response.getStatus());
    } else {
      return new TMDbToken(response.getData());
    }
  }