Skip to content

Fix custom browser user-agent failing the flow when canOpenURL: returns NO - #981

Open
federicobartoli wants to merge 1 commit into
openid:masterfrom
federicobartoli:fix/custom-browser-open-result
Open

federicobartoli wants to merge 1 commit into
openid:masterfrom
federicobartoli:fix/custom-browser-open-result

Conversation

@federicobartoli

Copy link
Copy Markdown

Fixes #980.

What

-[OIDExternalUserAgentIOSCustomBrowser presentExternalUserAgentRequest:session:] returned the result of canOpenURL: while calling openURL:options:completionHandler: regardless of it. When canOpenURL: answers NO for a URL that the system can open, the browser opened but the session was failed with "Unable to open Safari.", and the redirect that came back had no pending flow to resume.

The method now reports the request as presented and fails the session only if the open really fails, from the completion handler of openURL:options:completionHandler:. The error code and message are unchanged.

Notes

  • For a real failure the only observable change is timing: the same error is delivered from the completion handler instead of synchronously through the NO return value.
  • The "browser not installed, open the App Store" branch is untouched, and a nil transformed URL still returns NO.
  • OIDExternalUserAgentSession.h is now imported, as the other user-agents already do, because the method calls failExternalUserAgentFlowWithError:.
  • No public API change. A CHANGELOG entry is included.

Testing

  • On device (iPhone 15, iOS 27.0.1, Chrome as the default browser, Safari disabled through Screen Time, no https in LSApplicationQueriesSchemes, so canOpenURL: returns NO), with this change applied to AppAuth 2.0.0: Chrome opens, the session stays pending and the sign-in completes. Without the change the flow fails as described in Custom browser user-agent fails the flow with "Unable to open Safari." while the browser opens (it returns the result of canOpenURL:) #980.
  • xcodebuild test -project AppAuth.xcodeproj -scheme AppAuth-iOS on an iPhone 17 Pro simulator (iOS 26.1, Xcode 26.3): 169 tests, 15 skipped, 0 failures. No test covers this class, so this only shows that the change builds on master and that nothing else regressed.
  • Not tested: the Chrome, Firefox and Opera variants, and the failure path (a URL that really cannot be opened).

Contributor agreements

I have signed the Individual Contributor License Agreement.

@w-goog
w-goog self-requested a review October 19, 2026 22:26

This branch has not been deployed

No deployments
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.

Custom browser user-agent fails the flow with "Unable to open Safari." while the browser opens (it returns the result of canOpenURL:)

1 participant