fix: Phone Number Hint always returning "403 User denied consent"#121
Open
alaric505 wants to merge 1 commit intosurfstudio:mainfrom
Open
fix: Phone Number Hint always returning "403 User denied consent"#121alaric505 wants to merge 1 commit intosurfstudio:mainfrom
alaric505 wants to merge 1 commit intosurfstudio:mainfrom
Conversation
## Checklist - [x] Have you added an explanation of what your changes do and why you'd like us to include them? - [ ] Is there an existing issue for this PR? - [x] Have the files been linted and formatted? - [ ] Have the docs been updated to match the changes in the PR? - [ ] Have the tests been updated to match the changes in the PR? - [ ] Attached videos/screenshots demonstrating the fix/feature. - [ ] Have you run the tests locally to confirm they pass? ## Changes ### What is the current behavior, and the steps to reproduce the issue? When using `getTelephoneHint` to show the Phone Number Hint picker, selecting a phone number always returns a `"403 User denied consent"` error instead of the selected phone number. This happens because the `credentialPickerRequest` handler in `onActivityResult` checks `data.hasExtra(SmsRetriever.EXTRA_SMS_MESSAGE)` before extracting the phone number. That extra is only present in the **SMS User Consent** flow and is never set in the **Phone Number Hint** flow, so the check always returns `false` and falls into the error branch. ### What is the expected behavior? Selecting a phone number from the hint picker should successfully return the phone number to the Flutter side via `lastResult?.success(phoneNumber)`. ### How does this PR fix the problem? - Removed the incorrect `data.hasExtra(SmsRetriever.EXTRA_SMS_MESSAGE)` guard from the `credentialPickerRequest` handler. - Directly calls `Identity.getSignInClient(context).getPhoneNumberFromIntent(data)` wrapped in a `try/catch` to handle extraction failures gracefully (returns a `"500"` error with the exception message). - Moved the `"403 User denied consent"` error to the outer `else` branch, where it correctly fires only when the user actually dismisses the picker (`resultCode != RESULT_OK` or `data == null`).
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.
Checklist
Changes
What is the current behavior, and the steps to reproduce the issue?
When using
getTelephoneHintto show the Phone Number Hint picker, selecting a phone number always returns a"403 User denied consent"error instead of the selected phone number.This happens because the
credentialPickerRequesthandler inonActivityResultchecksdata.hasExtra(SmsRetriever.EXTRA_SMS_MESSAGE)before extracting the phone number. That extra is only present in the SMS User Consent flow and is never set in the Phone Number Hint flow, so the check always returnsfalseand falls into the error branch.What is the expected behavior?
Selecting a phone number from the hint picker should successfully return the phone number to the Flutter side via
lastResult?.success(phoneNumber).How does this PR fix the problem?
data.hasExtra(SmsRetriever.EXTRA_SMS_MESSAGE)guard from thecredentialPickerRequesthandler.Identity.getSignInClient(context).getPhoneNumberFromIntent(data)wrapped in atry/catchto handle extraction failures gracefully (returns a"500"error with the exception message)."403 User denied consent"error to the outerelsebranch, where it correctly fires only when the user actually dismisses the picker (resultCode != RESULT_OKordata == null).Tap on "Preview" ⤴
And choose one of the templates: