Class APIException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
RateLimitException

public class APIException extends Auth0Exception
Represents an Auth0 Server error captured from an HTTP response. Provides different methods to determine why the request failed. i.e.:
 
 {
      statusCode: 400,
      description: "Query validation error: 'String 'users' does not match pattern. Must be a comma separated list of the following values: name,strategy,options,enabled_clients,id,provisioning_ticket_url' on property fields (A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve all fields).",
      error: "invalid_query_string"
 }
 
 
See Also:
  • Constructor Details

    • APIException

      public APIException(String payload, int statusCode, Throwable cause)
    • APIException

      public APIException(Map<String,Object> values, int statusCode)
  • Method Details

    • getStatusCode

      public int getStatusCode()
      Getter for the Http Status Code received in the response. i.e. a status_code=403 would mean that the token has an insufficient scope.
      Returns:
      the status code.
    • getError

      public String getError()
      Getter for the exception error code. i.e. a error=invalid_query_string would mean that the query parameters sent in the request were invalid.
      Returns:
      the error code.
    • getValue

      public Object getValue(String key)
      Returns a value from the error map, if any.
      Parameters:
      key - key of the value to return
      Returns:
      the value if found or null
    • getDescription

      public String getDescription()
      Getter for the exception user friendly description of why the request failed. i.e. the description may say which query parameters are valid for that endpoint.
      Returns:
      the description.
    • isMultifactorRequired

      public boolean isMultifactorRequired()
      Returns:
      true when an MFA code is required to authenticate, false otherwise.
    • isInvalidCredentials

      public boolean isInvalidCredentials()
      Returns:
      true when the username and/or password used for authentication are invalid, false otherwise.
    • isMultifactorEnrollRequired

      public boolean isMultifactorEnrollRequired()
      Returns:
      true when MFA is required and the user is not enrolled, false otherwise.
    • isVerificationRequired

      public boolean isVerificationRequired()
      Returns:
      true when Bot Protection flags the request as suspicious, false otherwise.
    • isMultifactorTokenInvalid

      public boolean isMultifactorTokenInvalid()
      Returns:
      true when the MFA Token used on the login request is malformed or has expired, false otherwise.
    • isAccessDenied

      public boolean isAccessDenied()
      Returns:
      true when authenticating with web-based authentiction and the resource server denied access per the OAuth 2 spec, false otherwise.