Skip to content

Conversation

@pmathew92
Copy link
Contributor

@pmathew92 pmathew92 commented Jul 2, 2025

📋 Changes

This PR adds new properties in the web_authentication_exception and credentials_manager_exception class to easily compare for specific error scenarios

📎 References

#395

…entials_manager_exception class to easily check for specific error scenarios
code == 'RENEW_FAILED' ||
code ==
'''
An error occurred while trying to use the Refresh Token to renew the Credentials.''';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These need a proper error code on the Android side as well.

@NandanPrabhu
Copy link
Contributor

@pmathew92 iOS checks in the CI are failing but merge button is enabled. Is it expected?

@pmathew92
Copy link
Contributor Author

@pmathew92 iOS checks in the CI are failing but merge button is enabled. Is it expected?

Yes. The iOS smoke tests were failing for quite some time @Widcket might take a look into them if she has bandwidth

@pmathew92 pmathew92 merged commit 920b06a into main Jul 3, 2025
15 of 17 checks passed
@pmathew92 pmathew92 deleted the SDK-6189 branch July 3, 2025 05:31
This was referenced Jul 10, 2025
@wiesnery
Copy link

wiesnery commented Nov 6, 2025

@pmathew92 @Widcket @NandanPrabhu
I do have a question regarding this PR - it's great that you implemented these handy checks!
In the Android SDK, there is a AuthenticationException#isNetworkError check. Do you have an advice on how to check for this in flutter?

My use case (and I am wondering how others are solving it) -> If I do see an error during the credentialsManager.credentials() I want to invalidate my current credentials with credentialsManager.clearCredentials(), so that my user can login again. But if the error is just caused by a simple network error, I don't want to invalidate, so that my users don't have to login after every app open in flight mode.

I would be super happy for any advise from your side 😃

@pmathew92
Copy link
Contributor Author

Hi @wiesnery ,
Thank you for the suggestion. Agree we should add a property to check network errors. I will add them
Meanwhile you can use the code property within the CredentialsManagerException class to compare for the netwrok error against any other type of error

@wiesnery
Copy link

wiesnery commented Nov 7, 2025

Hi @pmathew92,
Thank you for your quick reply. I checked it and exception codes are different for iOS and Android. For Android, I digged through the code of the SecureCredentialsManger and around line 566, errors of all kind will just be wrapped to a kind of generic CredentialsManagerException with message = code "An error occurred while trying to use the Refresh Token to renew the Credentials." which makes it impossible to distinguish in the flutter code. This is although the underlying AuthenticationException is amazingly well with distinguishing error causes (maybe even a bit too specific for beginners like me).

Could you confirm my findings or prove me wrong (I prefer the latter xD) and/or give me a hint on how to proceed maybe not only on the exception handling level, but maybe what should be correctly done with my high level problem on when to clearCredentials() and when better not to?

Cheers!

@pmathew92
Copy link
Contributor Author

Hi @wiesnery , The current underlying Android SDK within the flutter SDK is quite old at the moment which returns generic error and makes it difficult to map to specific error scenario like in your cases. We are working on updating this with the latest version which can give much better error response. This new major version of the flutter sdk will be released soon within next two week. If possible, I would request you to wait till then

@wiesnery
Copy link

@pmathew92 could you tell me when I can expect the release of the new package version? I am still waiting and I postponed my bug-fix update because you told me that I should wait and that you gonna ship within two weeks. I know thinks sometimes take longer than expected - do you habe a new timeframe and the confirmation that my requested feature for more precise exceptions will be included?

@pmathew92
Copy link
Contributor Author

Hi @wiesnery , Apologies on this. We are working on a feature which we plan to release as part of the next release. It is under code review and might take few more days. We plan to make release sometime next week unless we odn't expect any major blocker on our side. Thanks for your understanding

@wiesnery
Copy link

Hi @pmathew92 thank you for your prompt reply!
One more week is not optimal, but our users will need to deal with it...
Could you also confirm, that my requested feature for more precise exceptions will be included?
Otherwise I can also ship without your update.
If so - is there a working branch, which I can use for development with the new API in the meanwhile? I saw #671 but this looks like it is stale for the moment.

@pmathew92
Copy link
Contributor Author

Hi @wiesnery ,
The new release we are doing will be a major release with some breaking changes as we are updating the underlying Android SDK and iOS SDK. This will a beta version which we are planning to release in the next week. #667 is the major feature we are working on to support on the flutter SDK to be released as part of it. This new version will also return the underlying AuthenticationExceptions with more precise errors as you requested. Hope this clarifies any doubts you have with respect to the release plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants