Skip to content

Commit a62ae51

Browse files
authored
docs: add instructions for using management api as alternative to dashboard ui (supabase#36676)
1 parent f1b67c3 commit a62ae51

24 files changed

+502
-0
lines changed

apps/docs/content/_partials/quickstart_db_setup.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,28 @@
22

33
Go to [database.new](https://database.new) and create a new Supabase project.
44

5+
Alternatively, you can create a project using the Management API:
6+
7+
```bash
8+
# First, get your access token from https://supabase.com/dashboard/account/tokens
9+
export SUPABASE_ACCESS_TOKEN="your-access-token"
10+
11+
# List your organizations to get the organization ID
12+
curl -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
13+
https://api.supabase.com/v1/organizations
14+
15+
# Create a new project (replace <org-id> with your organization ID)
16+
curl -X POST https://api.supabase.com/v1/projects \
17+
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
18+
-H "Content-Type: application/json" \
19+
-d '{
20+
"organization_id": "<org-id>",
21+
"name": "My Project",
22+
"region": "us-east-1",
23+
"password": "<your-secure-password>"
24+
}'
25+
```
26+
527
When your project is up and running, go to the [Table Editor](https://supabase.com/dashboard/project/_/editor), create a new table and insert some data.
628

729
Alternatively, you can run the following snippet in your project's [SQL Editor](https://supabase.com/dashboard/project/_/sql/new). This will create a `instruments` table with some sample data.

apps/docs/content/guides/auth/auth-email-templates.mdx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,36 @@ The templating system provides the following variables for use:
2929

3030
On hosted Supabase projects, edit your email templates on the [Email Templates](/dashboard/project/_/auth/templates) page. On self-hosted projects or in local development, edit your [configuration files](/docs/guides/local-development/customizing-email-templates).
3131

32+
You can also manage email templates using the Management API:
33+
34+
```bash
35+
# Get your access token from https://supabase.com/dashboard/account/tokens
36+
export SUPABASE_ACCESS_TOKEN="your-access-token"
37+
export PROJECT_REF="your-project-ref"
38+
39+
# Get current email templates
40+
curl -X GET "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \
41+
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
42+
| jq 'to_entries | map(select(.key | startswith("mailer_templates"))) | from_entries'
43+
44+
# Update email templates
45+
curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \
46+
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
47+
-H "Content-Type: application/json" \
48+
-d '{
49+
"mailer_subjects_confirmation": "Confirm your signup",
50+
"mailer_templates_confirmation_content": "<h2>Confirm your signup</h2><p>Follow this link to confirm your user:</p><p><a href=\"{{ .ConfirmationURL }}\">Confirm your email</a></p>",
51+
"mailer_subjects_magic_link": "Your Magic Link",
52+
"mailer_templates_magic_link_content": "<h2>Magic Link</h2><p>Follow this link to login:</p><p><a href=\"{{ .ConfirmationURL }}\">Log In</a></p>",
53+
"mailer_subjects_recovery": "Rest Your Password",
54+
"mailer_templates_recovery_content": "<h2>Reset Password</h2><p>Follow this link to reset the password for your user:</p><p><a href=\"{{ .ConfirmationURL }}\">Reset Password</a></p>",
55+
"mailer_subjects_invite": "You have been invited",
56+
"mailer_templates_invite_content": "<h2>You have been invited</h2><p>You have been invited to create a user on {{ .SiteURL }}. Follow this link to accept the invite:</p><p><a href=\"{{ .ConfirmationURL }}\">Accept the invite</a></p>",
57+
"mailer_subjects_email_change": "Confirm email change",
58+
"mailer_templates_email_change_content": "<h2>Confirm email change</h2><p>Follow this link to confirm the update of your email:</p><p><a href=\"{{ .ConfirmationURL }}\">Change email</a></p>",
59+
}'
60+
```
61+
3262
## Mobile deep linking
3363

3464
For mobile applications, you might need to link or redirect to a specific page within your app. See the [Mobile Deep Linking guide](/docs/guides/auth/native-mobile-deep-linking) to set this up.

apps/docs/content/guides/auth/auth-smtp.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,30 @@ A non-exhaustive list of services that work with Supabase Auth is:
5050

5151
Once you've set up your account with an email sending service, head to the [Authentication settings page](/dashboard/project/_/settings/auth) to enable and configure custom SMTP.
5252

53+
You can also configure custom SMTP using the Management API:
54+
55+
```bash
56+
# Get your access token from https://supabase.com/dashboard/account/tokens
57+
export SUPABASE_ACCESS_TOKEN="your-access-token"
58+
export PROJECT_REF="your-project-ref"
59+
60+
# Configure custom SMTP
61+
curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \
62+
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
63+
-H "Content-Type: application/json" \
64+
-d '{
65+
"external_email_enabled": true,
66+
"mailer_secure_email_change_enabled": true,
67+
"mailer_autoconfirm": false,
68+
"smtp_admin_email": "[email protected]",
69+
"smtp_host": "smtp.example.com",
70+
"smtp_port": 587,
71+
"smtp_user": "your-smtp-user",
72+
"smtp_pass": "your-smtp-password",
73+
"smtp_sender_name": "Your App Name"
74+
}'
75+
```
76+
5377
Once you save these settings, your project's Auth server will send messages to all addresses. To protect the reputation of your newly set up service a low rate-limit of 30 messages per hour is imposed. To adjust this to an acceptable value for your use case head to the [Rate Limits configuration page](/dashboard/project/_/auth/rate-limits).
5478

5579
## Dealing with abuse: How to maintain the sending reputation of your SMTP server?

apps/docs/content/guides/auth/rate-limits.mdx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,31 @@ subtitle: 'Rate limits protect your services from abuse'
55

66
Supabase Auth enforces rate limits on endpoints to prevent abuse. Some rate limits are [customizable](/dashboard/project/_/auth/rate-limits).
77

8+
You can also manage rate limits using the Management API:
9+
10+
```bash
11+
# Get your access token from https://supabase.com/dashboard/account/tokens
12+
export SUPABASE_ACCESS_TOKEN="your-access-token"
13+
export PROJECT_REF="your-project-ref"
14+
15+
# Get current rate limits
16+
curl -X GET "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \
17+
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
18+
| jq 'to_entries | map(select(.key | startswith("rate_limit_"))) | from_entries'
19+
20+
# Update rate limits
21+
curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \
22+
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
23+
-H "Content-Type: application/json" \
24+
-d '{
25+
"rate_limit_anonymous_users": 10,
26+
"rate_limit_email_sent": 10,
27+
"rate_limit_sms_sent": 10,
28+
"rate_limit_verify": 10,
29+
"rate_limit_token_refresh": 10,
30+
"rate_limit_otp": 10,
31+
"rate_limit_web3": 10
32+
}'
33+
```
34+
835
<$Partial path="auth_rate_limits.mdx" />

apps/docs/content/guides/auth/social-login/auth-apple.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,24 @@ When developing with Expo, you can test Sign in with Apple via the Expo Go app,
6767
6. Create a signing **Key** in the [Keys](https://developer.apple.com/account/resources/authkeys/list) section of the Apple Developer Console. You can use this key to generate a secret key using the tool below, which is added to your Supabase project's Auth configuration. Make sure you safely store the `AuthKey_XXXXXXXXXX.p8` file. If you ever lose access to it, or make it public accidentally, revoke it from the Apple Developer Console and create a new one immediately. You will have to generate a new secret key using this file every 6 months, so make sure you schedule a recurring meeting in your calendar!
6868
7. Finally, add the information you configured above to the [Apple provider configuration in the Supabase dashboard](https://supabase.com/dashboard/project/_/auth/providers).
6969

70+
You can also configure the Apple auth provider using the Management API:
71+
72+
```bash
73+
# Get your access token from https://supabase.com/dashboard/account/tokens
74+
export SUPABASE_ACCESS_TOKEN="your-access-token"
75+
export PROJECT_REF="your-project-ref"
76+
77+
# Configure Apple auth provider
78+
curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \
79+
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
80+
-H "Content-Type: application/json" \
81+
-d '{
82+
"external_apple_enabled": true,
83+
"external_apple_client_id": "your-services-id",
84+
"external_apple_secret": "your-generated-secret-key"
85+
}'
86+
```
87+
7088
<Admonition type="tip">
7189

7290
Use this tool to generate a new Apple client secret. No keys leave your browser! Be aware that this tool does not currently work in Safari, so use Firefox or a Chrome-based browser instead.

apps/docs/content/guides/auth/social-login/auth-azure.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,25 @@ Setting up OAuth with Azure consists of four broad steps:
4444

4545
![Obtain the client secret](/docs/img/guides/auth-azure/azure-client-secret.png)
4646

47+
You can also configure the Azure auth provider using the Management API:
48+
49+
```bash
50+
# Get your access token from https://supabase.com/dashboard/account/tokens
51+
export SUPABASE_ACCESS_TOKEN="your-access-token"
52+
export PROJECT_REF="your-project-ref"
53+
54+
# Configure Azure auth provider
55+
curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \
56+
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
57+
-H "Content-Type: application/json" \
58+
-d '{
59+
"external_azure_enabled": true,
60+
"external_azure_client_id": "your-azure-client-id",
61+
"external_azure_secret": "your-azure-client-secret",
62+
"external_azure_url": "your-azure-url"
63+
}'
64+
```
65+
4766
## Guarding against unverified email domains
4867

4968
Microsoft Entra ID can send out unverified email domains in certain cases. This may open up your project to a vulnerability where a malicious user can impersonate already existing accounts on your project.

apps/docs/content/guides/auth/social-login/auth-discord.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ Setting up Discord logins for your application consists of 3 parts:
4343

4444
<$Partial path="social_provider_settings_supabase.mdx" variables={{ "provider": "Discord" }} />
4545

46+
You can also configure the Discord auth provider using the Management API:
47+
48+
```bash
49+
# Get your access token from https://supabase.com/dashboard/account/tokens
50+
export SUPABASE_ACCESS_TOKEN="your-access-token"
51+
export PROJECT_REF="your-project-ref"
52+
53+
# Configure Discord auth provider
54+
curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \
55+
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
56+
-H "Content-Type: application/json" \
57+
-d '{
58+
"external_discord_enabled": true,
59+
"external_discord_client_id": "your-discord-client-id",
60+
"external_discord_secret": "your-discord-client-secret"
61+
}'
62+
```
63+
4664
## Add login code to your client app
4765

4866
<Tabs

apps/docs/content/guides/auth/social-login/auth-facebook.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,24 @@ Under `Build Your App`, click on `Use Cases` screen. From there, do the followin
6060

6161
<$Partial path="social_provider_settings_supabase.mdx" variables={{ "provider": "Facebook" }} />
6262

63+
You can also configure the Facebook auth provider using the Management API:
64+
65+
```bash
66+
# Get your access token from https://supabase.com/dashboard/account/tokens
67+
export SUPABASE_ACCESS_TOKEN="your-access-token"
68+
export PROJECT_REF="your-project-ref"
69+
70+
# Configure Facebook auth provider
71+
curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \
72+
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
73+
-H "Content-Type: application/json" \
74+
-d '{
75+
"external_facebook_enabled": true,
76+
"external_facebook_client_id": "your-facebook-app-id",
77+
"external_facebook_secret": "your-facebook-app-secret"
78+
}'
79+
```
80+
6381
## Add login code to your client app
6482

6583
<Tabs

apps/docs/content/guides/auth/social-login/auth-github.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,24 @@ Copy your new OAuth credentials
3838

3939
<$Partial path="social_provider_settings_supabase.mdx" variables={{ "provider": "GitHub" }} />
4040

41+
You can also configure the GitHub auth provider using the Management API:
42+
43+
```bash
44+
# Get your access token from https://supabase.com/dashboard/account/tokens
45+
export SUPABASE_ACCESS_TOKEN="your-access-token"
46+
export PROJECT_REF="your-project-ref"
47+
48+
# Configure GitHub auth provider
49+
curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \
50+
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
51+
-H "Content-Type: application/json" \
52+
-d '{
53+
"external_github_enabled": true,
54+
"external_github_client_id": "your-github-client-id",
55+
"external_github_secret": "your-github-client-secret"
56+
}'
57+
```
58+
4159
## Add login code to your client app
4260

4361
<Tabs

apps/docs/content/guides/auth/social-login/auth-google.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ To use your own application code:
5353

5454
1. When you finish configuring your credentials, you will be shown your client ID and secret. Add these to the [Google Auth Provider section of the Supabase Dashboard](/dashboard/project/_/auth/providers).
5555

56+
Alternatively, you can configure Google authentication using the Management API:
57+
58+
```bash
59+
# First, get your access token from https://supabase.com/dashboard/account/tokens
60+
export SUPABASE_ACCESS_TOKEN="your-access-token"
61+
export PROJECT_REF="your-project-ref"
62+
63+
# Update auth config to enable Google provider
64+
curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \
65+
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
66+
-H "Content-Type: application/json" \
67+
-d '{
68+
"external_google_enabled": true,
69+
"external_google_client_id": "your-google-client-id",
70+
"external_google_secret": "your-google-client-secret"
71+
}'
72+
```
73+
5674
<Admonition type="tip">
5775

5876
In local development, you can add the client ID and secret to your `config.toml` file.

0 commit comments

Comments
 (0)