Handle Android process death during web authentication#820
Merged
utkrishtsahu merged 3 commits intomainfrom Apr 30, 2026
Merged
Handle Android process death during web authentication#820utkrishtsahu merged 3 commits intomainfrom
utkrishtsahu merged 3 commits intomainfrom
Conversation
subhankarmaiti
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 Changes
On Android devices with aggressive battery management (Samsung, Xiaomi, Huawei, Oppo, Vivo), the OS kills the app process while the user is in the browser completing Auth0 login. When the browser redirects back, the app restarts fresh and the in-memory PKCE callback is lost — the authorization code is never exchanged for tokens. In Auth0 tenant logs, a successful login ("s") appears but no corresponding token exchange.
The native Auth0.Android SDK (since v3.4.0, PR #784) already handles process death — AuthenticationActivity serializes OAuthManager state (PKCE code_verifier, state nonce) into the Activity Bundle and restores it on recreation. The recovered credentials are delivered via WebAuthProvider.addCallback(). The Flutter plugin never registered this callback, so recovered credentials were silently discarded.
What changed:
New public API:
Stream<Credentials> get onCredentialsRecoveredDeveloper usage:
📎 References
ESD-59215
🎯 Testing
Unit tests: Not added — the fix bridges native SDK behavior (WebAuthProvider.addCallback) that requires a real Android Activity lifecycle and process death simulation, which cannot be meaningfully unit tested.
Manual end-to-end testing (verified on Pixel 7a, device 38261JEHN01576):
adb shell am kill <your.package.name>
⚠️ "Don't keep activities" in Developer Options is not sufficient — it only destroys the Activity but keeps the process alive. You must use adb shell am kill to simulate true process death.
5.Complete login in the browser — the redirect fires, Android restores the app
6.Verify: onCredentialsRecovered stream emits credentials with valid accessToken, idToken, refreshToken, expiresAt, and tokenType
Test result: PASS — all token fields present, user authenticated successfully after process death recovery.