We are having to migrate an existing app from 10.2.9 to 100.6 for Google's new 64bit compatibility requirement.
We have most of the app converted apart from one section concerning authentication handling.
In 10.2.9 we were able to get detailed errors from a failed login using EsriSecurityException but we have been unable to find any replacement that gives us the same level of error detail. Errors generated via the new AuthenticationManager are just a generic response stating that we do not have access to the resource, without giving an underlying cause, such as "Invalid username or password".
I have trawled through all the documentation and can find nothing concerning this.
Has anybody tried this and managed to get detailed responses?
Solved! Go to Solution.
Hi Simon,
Sorry for lacking of appropriate documentation concerning dealing with authentication errors. We have created issues and will endeavor to improve our documentation in future releases.
Starting from 100.0, errors thrown from our SDK are wrapped in a class called ArcGISRuntimeException. More specific information of where the error occurred and what caused it are provided via getErrorDomain(),
getErrorCode()
and getCause(). In regard to obtaining detailed error message when an authentication fails, you can work with ArcGISRuntimeException in the similar way as EsriSecurityException as shown in the following code snippet:
Throwable cause = error.getCause();
if (cause == null) {
Log.i(tag, "error without a cause - code: " + error.getErrorCode() + "; " + error.getMessage());
} else {
if (cause instanceof JsonEmbeddedException) {
JsonEmbeddedException jsonError = (JsonEmbeddedException) cause;
Log.i(tag, "error with cause: JsonEmbeddedException - code: " + jsonError.getCode()
+ " message: " + jsonError.getMessage());
} else {
Log.i(tag, "error with cause: " + cause.getClass().getSimpleName() + " - code: " + error.getErrorCode()
+ " message: " + cause.getMessage());
}
}
The followings are some example printout from the above code snippet in some error cases:
1. Passing wrong credential to a token-based portal/layer
error with cause: JsonEmbeddedException - code: 400 message: Unable to generate token.
2. Passing wrong credential to aN IWA portal/layer
error with cause: HttpResponseException - code: 22 message: status code: 401, reason phrase: Unauthorized: Access is denied due to invalid credentials.
Please share more info regarding your workflow if you still have problem in handling error message.
Thanks,
Hi Simon,
Sorry for lacking of appropriate documentation concerning dealing with authentication errors. We have created issues and will endeavor to improve our documentation in future releases.
Starting from 100.0, errors thrown from our SDK are wrapped in a class called ArcGISRuntimeException. More specific information of where the error occurred and what caused it are provided via getErrorDomain(),
getErrorCode()
and getCause(). In regard to obtaining detailed error message when an authentication fails, you can work with ArcGISRuntimeException in the similar way as EsriSecurityException as shown in the following code snippet:
Throwable cause = error.getCause();
if (cause == null) {
Log.i(tag, "error without a cause - code: " + error.getErrorCode() + "; " + error.getMessage());
} else {
if (cause instanceof JsonEmbeddedException) {
JsonEmbeddedException jsonError = (JsonEmbeddedException) cause;
Log.i(tag, "error with cause: JsonEmbeddedException - code: " + jsonError.getCode()
+ " message: " + jsonError.getMessage());
} else {
Log.i(tag, "error with cause: " + cause.getClass().getSimpleName() + " - code: " + error.getErrorCode()
+ " message: " + cause.getMessage());
}
}
The followings are some example printout from the above code snippet in some error cases:
1. Passing wrong credential to a token-based portal/layer
error with cause: JsonEmbeddedException - code: 400 message: Unable to generate token.
2. Passing wrong credential to aN IWA portal/layer
error with cause: HttpResponseException - code: 22 message: status code: 401, reason phrase: Unauthorized: Access is denied due to invalid credentials.
Please share more info regarding your workflow if you still have problem in handling error message.
Thanks,