GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fail the authorization flow instead of crashing when a code flow redirect has no code by Mohith26 · Pull Request #994 · openid/AppAuth-iOS

Conversation

@Mohith26

@Mohith26 Mohith26 commented Nov 9, 2026

Copy link
Copy Markdown

Fixes #813.

A redirect for the code (or code id_token) response type that has no code parameter and no error parameter is currently delivered as a successful OIDAuthorizationResponse with authorizationCode == nil. OIDAuthState's convenience flow then calls tokenExchangeRequest on it, which raises kTokenExchangeRequestException, so the app crashes instead of getting an error in the callback.

This adds a check in resumeExternalUserAgentFlowWithURL:error:, right after the state validation: if the request's response type includes code and the response has none, the flow fails with OIDOAuthAuthorizationErrorDomain / OIDErrorCodeOAuthAuthorizationClientError, the same error the state check uses, with a message that names the missing parameter (RFC 6749 section 4.1.2). Checking at the session level rather than only in OIDAuthState also covers apps that call OIDAuthorizationService directly and do the exchange themselves. The order of checks is unchanged: an OAuth error response is still reported as the server's error, and a state mismatch still wins.

Tests (in OIDAuthorizationServiceTests, driven through a small synchronous fake OIDExternalUserAgent):

  • code flow without code returns the client error and no response
  • code id_token without code returns the client error
  • code flow with code still succeeds
  • error=access_denied still maps to OIDErrorCodeOAuthAuthorizationAccessDenied
  • state mismatch is still reported as a state mismatch when the code is also missing
  • OIDAuthState convenience flow calls back with the error instead of raising (on current master this test fails with the kTokenExchangeRequestException from the issue)

Ran the AppAuth_macOS test bundle locally (Xcode 27.2, Apple Silicon): 180 tests, 0 failures. I don't have an iOS simulator runtime on this machine, so I haven't run the iOS scheme; the change is in AppAuthCore only. Added a CHANGELOG entry under UNRELEASED.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Mohith26
Fail the authorization flow when a code flow redirect has no code
fa3a044
A redirect for the code (or code id_token) response type without a
code parameter was delivered as a successful OIDAuthorizationResponse
with a nil authorizationCode. OIDAuthState's convenience flow then
called tokenExchangeRequest, which raises kTokenExchangeRequestException
and crashes the app.

Validate the code in resumeExternalUserAgentFlowWithURL:error:, after
the state check, and fail the flow with
OIDErrorCodeOAuthAuthorizationClientError like the state validation
does. Fixes openid#813.
@w-goog

w-goog commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Hi Mohit! I notice that your LLM hasn't tested on iOS simulators - please do so. And make sure to review your LLM output before posting it :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

No code query parameter in the redirect url throws exception

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Mohith26 @w-goog
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.