Open danallen88 opened 6 months ago
I have the exact same thing in my app
if (e.code == "USER_CANCELLED" ||
e.code == "a0.authentication_canceled") {
// user closed the login webpage
store.dispatch(const LoginFailedAction("Login cancelled"));
return;
}
There are differences when tokens fail to refresh while offline as well. The android "code" is not even really a code, it's a full sentence (same as the message).
static const _androidRefreshErrorCode =
"An error occurred while trying to use the Refresh Token to renew the Credentials.";
static const _iOSRefreshErrorCode = "RENEW_FAILED";
It would be very nice to have the codes be identical on all platforms
Checklist
Describe the problem you'd like to have solved
Users cancelling a web authentication session workflow results in a
WebAuthenticationException
with an internalcode
field that describes the cause for the exception. Presumably this is because many things could cause this type of exception.I have a use case where knowing specifically that the user cancelled the session is helpful, but in order to identify whether this action was taken by a user, I must inspect the code for each platform that can throw it (iOS and Android for me) and determine whether the code is either
USER_CANCELLED
(iOS) ora0.authentication_canceled
(Android). These appear to be platform-specific codes that are emitted from a native layer.Describe the ideal solution
Ideally there is an exception type that wraps any scenario where a user cancelled the web authentication session, perhaps by subclassing
WebAuthenticationException
with a new exceptionUserCancelledWebAuthenticationException
. Internal to the SDK, this exception can be created by inspecting the variety of codes that indicate the exception, and create a single exception that could be caught and dealt with.Alternatives and current workarounds
As it stands, this is the class I am using to capture these codes:
Then in my login method I am doing something like the following:
Additional context
No response