Package com.auth0.exception
Class APIException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.io.IOException
com.auth0.exception.Auth0Exception
com.auth0.exception.APIException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
RateLimitException
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 Summary
ConstructorDescriptionAPIException
(String payload, int statusCode, Throwable cause) APIException
(Map<String, Object> values, int statusCode) -
Method Summary
Modifier and TypeMethodDescriptionGetter for the exception user friendly description of why the request failed.getError()
Getter for the exception error code.int
Getter for the Http Status Code received in the response.Returns a value from the error map, if any.boolean
boolean
boolean
boolean
boolean
boolean
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
APIException
-
APIException
-
-
Method Details
-
getStatusCode
public int getStatusCode()Getter for the Http Status Code received in the response. i.e. astatus_code=403
would mean that the token has an insufficient scope.- Returns:
- the status code.
-
getError
Getter for the exception error code. i.e. aerror=invalid_query_string
would mean that the query parameters sent in the request were invalid.- Returns:
- the error code.
-
getValue
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
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.
-