Closed idomo1 closed 2 years ago
Thanks for the report, I'll take a look and see if I can reproduce.
It looks like this has less to do with the android version, and more to do with the current cache state. We cache the .well-known/openid-configuration
, and if that cache exists, it takes much less time to get the value to perform the rest of the flow. So it's getting to the point where we call the cancel callback before your delay is over.
That being said. What is your use case for this? I'm working on a new kotlin/coroutine based SDK, and I'd like to make sure we're handling this properly before a 1.0 release.
As for a workaround in the current SDK, I'd suggest calling unregisterCallback()
before cancel()
, and calling your centralized cancel logic afterwards.
The biggest issue here is cancel doesn't really cancel the flow, and it can't due to the way activities work in Android (we launch an activity we don't have control over, ie Chrome).
Cancel really only makes sense for cancelling the result handling due to this issue.
Thanks for looking into this. The use case is to let user press back to cancel the login flow in the time between client.signIn()
and Chrome opening. It's just a nice to have, not something that's essential.
The problem I can see with just unregistering the callback is that cancel
isn't guaranteed to work, so without the callback we don't know if it really was cancelled (please correct me if I'm wrong). Something that might work is to just add logic to treat the next onError
as a cancel after calling cancel()
.
I see, that use case is correctly accounted for in the new SDK.
So unfortunately calling cancel
doesn't actually cancel the network request in this SDK, but it will in the new SDK!
That being said, we can check for if the flow has been cancelled via cancel
when the network request ends up failing, and properly report the cancellation. I've got a proof of concept doing just that locally. But I'll figure out if it's the right thing to do, and finish it up next week.
All that being said. I still think the "work around" I outlined above is the best approach, so the user doesn't have to wait for the network call to complete before you let them move on.
@idomo1 fixed and released as 1.2.6.
Describe the bug?
When
WebAuthClient.cancel()
is called on some Android versions, theonError
callback is invoked. I've found this when testing on emulators. I don't have the devices on hand to test whether it happens on real devices as well.What is expected to happen?
The
onCancel
callback is invoked.What is the actual behavior?
The following exception:
Android 8, 8.1, 9, 10, 12
Or sometimes
Reproduction Steps?
signIn
cancel
Additional Information?
No response
SDK Version
1.2.5
Build Information
Android 8, 8.1, 9, 10, 12