Supabase. Auth. Admin. OAuth
(supabase_auth v1.0.1)
View Source
Admin OAuth 2.1 client management for Supabase Auth.
Provides functions to manage OAuth clients programmatically via the admin API.
All operations require a client configured with a service_role key.
Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
Client Lifecycle
# Create a new OAuth client
{:ok, client} = Admin.OAuth.create_client(supabase, %{
client_name: "My App",
redirect_uris: ["https://myapp.com/callback"]
})
# List all clients
{:ok, clients, pagination} = Admin.OAuth.list_clients(supabase)
# Update a client
{:ok, updated} = Admin.OAuth.update_client(supabase, client.client_id, %{
client_name: "My Renamed App"
})
# Regenerate client secret
{:ok, rotated} = Admin.OAuth.regenerate_client_secret(supabase, client.client_id)
# Delete a client
:ok = Admin.OAuth.delete_client(supabase, client.client_id)
Summary
Functions
Creates a new OAuth client.
Deletes an OAuth client.
Gets details of a specific OAuth client.
Lists all OAuth clients with optional pagination.
Regenerates the secret for an OAuth client.
Updates an existing OAuth client.
Functions
Creates a new OAuth client.
Parameters
client- TheSupabaseclient to use for the request.attrs- The client attributes:client_name- Human-readable name (required)redirect_uris- List of allowed redirect URIs (required, min 1)client_uri- URI of the OAuth clientgrant_types- Allowed grant types (defaults to["authorization_code", "refresh_token"])response_types- Allowed response types (defaults to["code"])scope- Scope stringtoken_endpoint_auth_method- One of"none","client_secret_basic","client_secret_post"
Returns
{:ok, oauth_client}- The created client (includesclient_secret){:error, error}- Failed to create client
Examples
iex> attrs = %{client_name: "My App", redirect_uris: ["https://myapp.com/callback"]}
iex> Supabase.Auth.Admin.OAuth.create_client(client, attrs)
{:ok, %{client_id: "...", client_name: "My App", client_secret: "...", ...}}
Deletes an OAuth client.
Parameters
client- TheSupabaseclient to use for the request.client_id- The ID of the OAuth client to delete.
Returns
:ok- Successfully deleted the client{:error, error}- Failed to delete client
Examples
iex> Supabase.Auth.Admin.OAuth.delete_client(client, "client-uuid")
:ok
Gets details of a specific OAuth client.
Parameters
client- TheSupabaseclient to use for the request.client_id- The ID of the OAuth client to retrieve.
Returns
{:ok, oauth_client}- The OAuth client details{:error, error}- Failed to retrieve client
Examples
iex> Supabase.Auth.Admin.OAuth.get_client(client, "client-uuid")
{:ok, %{client_id: "client-uuid", client_name: "My App", ...}}
Lists all OAuth clients with optional pagination.
Parameters
client- TheSupabaseclient to use for the request.params- Optional pagination parameters:page- Page number (default: 1)per_page- Number of clients per page
Returns
{:ok, clients, pagination}- List of OAuth clients with pagination info{:error, error}- Failed to list clients
Examples
iex> Supabase.Auth.Admin.OAuth.list_clients(client)
{:ok, [%{client_id: "...", client_name: "My App", ...}], %{next_page: 2, last_page: 5, total: 42}}
Regenerates the secret for an OAuth client.
The previous secret is immediately invalidated.
Parameters
client- TheSupabaseclient to use for the request.client_id- The ID of the OAuth client.
Returns
{:ok, oauth_client}- The client with the newclient_secret{:error, error}- Failed to regenerate secret
Examples
iex> Supabase.Auth.Admin.OAuth.regenerate_client_secret(client, "client-uuid")
{:ok, %{client_id: "client-uuid", client_secret: "new-secret-...", ...}}
Updates an existing OAuth client.
Parameters
client- TheSupabaseclient to use for the request.client_id- The ID of the OAuth client to update.attrs- The attributes to update (all optional):client_name- Human-readable nameclient_uri- URI of the OAuth clientlogo_uri- URI of the client's logoredirect_uris- List of allowed redirect URIsgrant_types- Allowed grant typestoken_endpoint_auth_method- Token endpoint auth method
Returns
{:ok, oauth_client}- The updated client{:error, error}- Failed to update client
Examples
iex> Supabase.Auth.Admin.OAuth.update_client(client, "client-uuid", %{client_name: "New Name"})
{:ok, %{client_id: "client-uuid", client_name: "New Name", ...}}