Skip to content

feat(gotrue): add user-facing OAuth 2.1 server authorization API#1483

Open
gourabsingha1 wants to merge 2 commits into
supabase:mainfrom
gourabsingha1:feat/gotrue-oauth-server-authorization-api
Open

feat(gotrue): add user-facing OAuth 2.1 server authorization API#1483
gourabsingha1 wants to merge 2 commits into
supabase:mainfrom
gourabsingha1:feat/gotrue-oauth-server-authorization-api

Conversation

@gourabsingha1

Copy link
Copy Markdown

Description

This PR implements the user-facing OAuth 2.1 server authorization consent flow methods on the GoTrueClient under the namespace oauthServer (via client.oauthServer).

These methods are useful when your Supabase project acts as an OAuth 2.1 server and you are building a custom consent/authorization screen.

The following user-facing consent endpoints are exposed:

  • client.oauthServer.getAuthorizationDetails(authorizationId): Retrieve client details and requested scopes for a pending authorization request.
  • client.oauthServer.approveAuthorization(authorizationId, {skipBrowserRedirect}): Approve the authorization request.
  • client.oauthServer.denyAuthorization(authorizationId, {skipBrowserRedirect}): Deny the authorization request.

Suggested Solution Context

Addresses: #1475

Test Plan

Added a comprehensive suite of unit tests in packages/gotrue/test/src/gotrue_oauth_server_api_test.dart that validates request paths, HTTP methods, body payloads, query parameters, and JSON response deserialization for all three methods. All tests pass successfully.

Adds the user-facing OAuth 2.1 server authorization consent flow methods:
- `getAuthorizationDetails(authorizationId)` (GET `/oauth/authorizations/{id}`)
- `approveAuthorization(authorizationId, {skipBrowserRedirect})` (POST `/oauth/authorizations/{id}/consent` with action: 'approve')
- `denyAuthorization(authorizationId, {skipBrowserRedirect})` (POST `/oauth/authorizations/{id}/consent` with action: 'deny')

These are exposed on GoTrueClient via `client.oauthServer`. Also added a comprehensive test suite in `gotrue_oauth_server_api_test.dart`.

Closes supabase#1475
@gourabsingha1 gourabsingha1 requested a review from a team as a code owner June 27, 2026 19:21
Fixes DCM lint warning avoid-unused-local-variable and ensures dart format
passes on CI.
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.

1 participant