Skip to content

fix(auth): recognize error query parameter in auth callback redirects - #1472

Merged
spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-1032-parityauth-recognize-error-parameter-in-implicit-grant
Jun 26, 2026
Merged

spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-1032-parityauth-recognize-error-parameter-in-implicit-grant

Conversation

@spydon

@spydon spydon commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What

OAuth error redirects can arrive as query parameters without an error_description (e.g. ?error=access_denied), per RFC 6749 §4.1.2.1 where error_description is optional but error is required.

Previously these bare ?error= redirects were silently dropped in two places:

  1. supabase_auth.dart → _isAuthCallbackDeeplink only matched error_description, so a ?error=access_denied deep link was never recognized as an auth callback.
  2. gotrue_client.dart → getSessionFromUrl only threw when error_description != null, so even if the gate passed, a bare ?error= fell through to the misleading "No access_token detected." instead of surfacing the actual OAuth error.

The result was that the user saw no feedback when an OAuth provider returned an error without a description.

Changes

  • Widened the deep link gate to also match error and error_code.
  • Made getSessionFromUrl throw for any of error / error_code / error_description, with a fallback message when no description is given. The error -> code and error_code -> statusCode mapping is preserved.

Tests

  • packages/gotrue/test/provider_test.dart: new case for ?error=access_denied&error_code=403 asserting the AuthException carries the code and status.
  • packages/supabase_flutter/test/deep_link_test.dart: new group asserting a ?error= deep link triggers getSessionFromUrl and surfaces the AuthException on onAuthStateChange.

Parity

Ports supabase-js#2407 to Dart/Flutter.

Resolves SDK-1032 (and its duplicate SDK-1044).

OAuth error redirects can arrive as query parameters without an
error_description (e.g. ?error=access_denied), per RFC 6749 4.1.2.1
where error_description is optional. The deep link gate only matched
error_description and getSessionFromUrl only threw when
error_description was present, so bare error redirects were silently
dropped and the user saw no feedback.

Widen the deep link gate to also match error and error_code, and make
getSessionFromUrl throw for any of error, error_code, or
error_description, falling back to a generic message when no
description is given.
@spydon
spydon requested a review from a team as a code owner June 26, 2026 08:44
@github-actions github-actions Bot added the auth This issue or pull request is related to authentication label Jun 26, 2026
@spydon
spydon merged commit cb7e7e6 into main Jun 26, 2026
28 checks passed
@spydon
spydon deleted the lukasklingsbo/sdk-1032-parityauth-recognize-error-parameter-in-implicit-grant branch June 26, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth This issue or pull request is related to authentication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants