Sign In / Providers
In short: set your app’s URLs in Supabase, plug Resend in as the email sender, switch on the
sign-in methods you want on Authentication → Sign In / Providers, and call one Supabase
function per method. Google and Microsoft both send users back to the same Supabase callback URL:
https://<your-project-ref>.supabase.co/auth/v1/callback.
There’s a script that does the Microsoft side for you.
Overview
What: this guide follows the Supabase dashboard page Authentication → Sign In / Providers. It’s where you choose how people sign in to your app with Supabase Auth, Supabase’s built-in user sign-in service. It covers the methods most apps need, plus Resend for sending the emails and Google and Microsoft Entra ID for signing in with an existing account:
| Method | What the user does | Supabase function |
|---|---|---|
| Email and password | Types an email and a password | signUp(), signInWithPassword() |
| Magic link | Clicks a link in an email | signInWithOtp() |
| Email code (OTP) | Types a 6-digit code from an email | signInWithOtp(), then verifyOtp() |
| Password reset | Clicks a link, picks a new password | resetPasswordForEmail(), then updateUser() |
| Picks their Google account | signInWithOAuth({ provider: 'google' }) |
|
| Microsoft | Signs in with their Microsoft 365 or Outlook account | signInWithOAuth({ provider: 'azure' }) |
It also covers Resend, which sends the sign-up, magic link and password reset emails. Supabase’s own email sender is only for testing, so every live app needs one.
Why: letting people sign in with an account they already have (Google or Microsoft) gets them into your app faster, and email sign-in covers everyone else. Supabase Auth runs all of it for you, so you don’t build or host your own login server.
Who it’s for: developers with a Supabase project who are adding sign-in for the first time, or adding another way to sign in. You don’t need to have used Google Cloud, Microsoft Entra ID or Resend before.
You don’t need every method. Do Steps 1 and 2, then pick the steps for the methods you want.
Prerequisites
| What | Details |
|---|---|
| Supabase project | You need its project ref: the <your-project-ref> part of https://<your-project-ref>.supabase.co. It’s also under Project Settings → General. No project yet? Follow Org and Project Creation first. |
| Supabase role | Owner or Administrator on the project, to change Auth settings. |
| Your app’s URL | Where users land after signing in, e.g. https://app.<your-domain>, plus http://localhost:3000 for development. |
| A domain you control | For Resend (Step 2). You’ll add DNS records to it, so you need access to your DNS provider (Cloudflare, Route 53, GoDaddy, …). |
| Resend account | Free at resend.com. The free plan is enough to start. |
| Google account | For Google sign-in (Step 4). Any Google account can create a Google Cloud project. |
| Microsoft Entra ID tenant | For Microsoft sign-in (Step 5). Members can create app registrations by default; otherwise ask for the Application Developer role. |
| Tools | @supabase/supabase-js 2.x in your app. Optional: Azure CLI 2.37 or newer (az version) for the Microsoft script, Supabase CLI 2 or newer for local development. |
About the code: the examples are JavaScript and use @supabase/supabase-js, so the browser ones work in any framework. Two parts assume a framework, and you swap them for yours:
- The client setup in 3.3 reads its settings with Vite’s
import.meta.env.VITE_.... In Next.js useprocess.env.NEXT_PUBLIC_.... Without a build tool, paste the two values in. - The server-side routes in 3.6 and 5.6 are for the Next.js App Router with
@supabase/ssr. Other server frameworks follow the same steps with their own request and redirect helpers.
Architecture
Every sign-in method goes through Supabase Auth. Your app never talks to Google, Microsoft or Resend directly. It asks Supabase, and Supabase hands back a session (the signed-in user’s tokens).
flowchart LR
classDef user fill:#CBD5E1,stroke:#475569,color:#060913
classDef app fill:#38BDF8,stroke:#0284C7,color:#000810
classDef cloud fill:#0B1121,stroke:#38BDF8,color:#E2E8F0
classDef data fill:#075985,stroke:#38BDF8,color:#F8FAFC
classDef secret fill:#F59E0B,stroke:#B45309,color:#1C1917
U([User]):::user -->|clicks sign in| A[Your app]:::app
A <-->|sign-in call / session| SB[Supabase Auth]:::cloud
K{{Client secrets<br/>Resend API key}}:::secret -.->|pasted into dashboard| SB
SB -->|users + identities| DB[(auth.users)]:::data
SB -->|SMTP: link or code| R[Resend]:::cloud
R -->|email| I([User's inbox]):::user
SB <-->|OAuth: code + tokens| G[Google]:::cloud
SB <-->|OAuth: code + tokens| M[Microsoft Entra ID]:::cloud
Figure 1: Supabase Auth sits in the middle. It sends emails through Resend and swaps codes for tokens with Google and Microsoft.
There are two kinds of flow.
Email flows (magic link, code, confirm email, password reset). Supabase sends an email through Resend, and the user proves they own the address by clicking the link or typing the code:
%%{init: {"theme": "base", "themeVariables": {"actorBkg": "#0B1121", "actorBorder": "#38BDF8", "actorTextColor": "#E2E8F0", "actorLineColor": "#718096", "signalColor": "#718096", "signalTextColor": "#718096", "textColor": "#718096", "loopTextColor": "#718096", "labelBoxBkgColor": "#38BDF8", "labelBoxBorderColor": "#0284C7", "labelTextColor": "#000810", "sequenceNumberColor": "#FFFFFF", "noteBkgColor": "#F59E0B", "noteBorderColor": "#B45309", "noteTextColor": "#1C1917"}}}%%
sequenceDiagram
autonumber
box rgba(148,163,184,0.15) Person
participant U as User
end
box rgba(56,189,248,0.15) Your app
participant A as Your app
end
box rgba(148,163,184,0.06) Services you use
participant SB as Supabase Auth
participant R as Resend (SMTP)
end
U->>A: Types their email
A->>SB: signInWithOtp({ email })
SB->>R: Send the "Magic link" email
R-->>U: Email with a link and/or a 6-digit code
alt Magic link
U->>SB: Clicks the link
SB-->>A: Redirect to your app with a session
else Code
U->>A: Types the code
A->>SB: verifyOtp({ email, token, type: 'email' })
SB-->>A: Session
end
Figure 2: The email flow, top to bottom. Resend only delivers the email. Supabase checks the link, or the code your app sends it.
OAuth flows (Google and Microsoft). The user signs in on Google’s or Microsoft’s own page, which sends them back to Supabase, not to your app:
%%{init: {"theme": "base", "themeVariables": {"actorBkg": "#0B1121", "actorBorder": "#38BDF8", "actorTextColor": "#E2E8F0", "actorLineColor": "#718096", "signalColor": "#718096", "signalTextColor": "#718096", "textColor": "#718096", "loopTextColor": "#718096", "labelBoxBkgColor": "#38BDF8", "labelBoxBorderColor": "#0284C7", "labelTextColor": "#000810", "sequenceNumberColor": "#FFFFFF", "noteBkgColor": "#F59E0B", "noteBorderColor": "#B45309", "noteTextColor": "#1C1917"}}}%%
sequenceDiagram
autonumber
box rgba(148,163,184,0.15) Person
participant U as User
end
box rgba(56,189,248,0.15) Your app
participant A as Your app
end
box rgba(148,163,184,0.06) Services you use
participant SB as Supabase Auth
participant P as Google or Microsoft
end
U->>A: Clicks "Sign in with Google" (or Microsoft)
A->>SB: signInWithOAuth({ provider })
SB-->>U: Sends them to the provider's sign-in page
U->>P: Signs in and agrees to share their details
P-->>SB: Code, to /auth/v1/callback
SB->>P: Swaps the code for the user's details (client ID + secret)
SB->>SB: Creates or updates the user in auth.users
SB-->>A: Session, at your redirectTo URL
Figure 3: The OAuth flow, top to bottom. The provider only ever talks to Supabase, never to your app.
That gives you the two rules behind most setup problems:
| Rule | Why |
|---|---|
| The redirect URI you give Google or Microsoft is the Supabase callback, not your app’s URL. | Step 5 in Figure 3: the provider sends the code to Supabase. |
| Your app’s URLs go in Supabase → Authentication → URL Configuration. | Step 8: Supabase decides where to send the user afterwards, and only goes to URLs on that list. |
Step 1: Set Your Site URL and Redirect URLs
Every method uses these, so set them first.
- In the Supabase dashboard, open Authentication → URL Configuration.
- In Site URL, type your production app’s address, e.g.
https://app.<your-domain>. - Select Save.
- Under Redirect URLs, select Add URL.
- Add every other place you send users back to, one per line. For example:
http://localhost:3000/**for local developmenthttps://<your-preview-prefix>-*.vercel.app/**for preview deploys
- Select Save URLs.
The Site URL is the default. If the redirectTo your code passes isn’t on the Redirect URLs list, Supabase quietly uses the Site URL instead. That’s the usual cause of “why does it keep sending me to production?”.
** matches any path, so http://localhost:3000/** covers /auth/callback, /account/update-password and everything else.
Step 2: Send Auth Emails with Resend
2.1 Why You Need Your Own Email Sender
Supabase comes with a built-in email sender so you can try Auth out. It isn’t meant for real users:
- It only sends to the email addresses of your Supabase organisation’s team members. Anyone else gets the error
email_address_not_authorized. - It sends a handful of emails per hour for the whole project (2 an hour when this guide was written). After that, sign-ups fail with
email rate limit exceeded. - Delivery is best effort, and emails come from a Supabase address, so they often land in spam.
Resend is an email service that Supabase can use over SMTP (the standard protocol for sending email). Once it’s set up, emails come from your own domain and can go to anyone.
2.2 Add and Verify Your Domain in Resend
Resend can only send from a domain you’ve proved you own. You prove it by adding DNS records.
- Sign in to Resend and open Domains.
- Select Add Domain.
- Type the domain you’ll send from. A subdomain such as
auth.<your-domain>is a good choice: it keeps sign-in emails separate from your other email, so a problem with one doesn’t hurt the other. - Pick the region closest to your users, then select Add.
- Resend now lists the DNS records to add. Keep this page open.
Add each record at your DNS provider, copying the name and value exactly from Resend. They look like this:
| Type | Name (host) | Value | What it’s for |
|---|---|---|---|
MX |
send.auth |
feedback-smtp.<region>.amazonses.com (priority 10) |
Lets bounce reports come back to Resend |
TXT |
send.auth |
v=spf1 include:amazonses.com ~all |
SPF: says Resend is allowed to send for your domain |
TXT |
resend._domainkey.auth |
p=<long-public-key-from-resend> |
DKIM: a signature that proves the email wasn’t changed on the way |
TXT |
_dmarc |
v=DMARC1; p=none; |
DMARC (recommended): tells inboxes what to do with mail that fails the checks |
When they’re all saved:
- Back in Resend, select Verify DNS Records.
- Wait until the domain shows Verified. It’s often a few minutes, but DNS can take up to 72 hours.
Many DNS providers add your domain to the end of the name for you. If you type send.auth.<your-domain> they may save send.auth.<your-domain>.<your-domain>, and the check never passes. Type just the part Resend shows, then check what was saved.
Once the domain is verified, you can tighten DMARC.
Start DMARC on p=none (report only). Once you’re sure all your real email passes, change it to p=quarantine so fakes go to spam.
2.3 Create a Resend API Key
The API key is the password Supabase uses to send through Resend.
- In Resend, open API Keys.
- Select Create API Key.
- In Name, type something you’ll recognise, e.g.
supabase-auth-<your-project-ref>. - In Permission, choose Sending access (not Full access).
- In Domain, choose the domain you verified in 2.2.
- Select Add, then copy the key. It starts with
re_and is only shown once.
Security: treat the API key like a password. Paste it straight into Supabase and your password manager. Don’t put it in your app’s code or in a .env file that gets committed.
2.4 Turn On Custom SMTP in Supabase
- In the Supabase dashboard, open Authentication → Emails.
- Open the SMTP Settings tab.
- Switch on Enable custom SMTP.
- Fill in the fields:
| Field | Value |
|---|---|
| Sender email address | An address on your verified domain, e.g. no-reply@auth.<your-domain>. It doesn’t need a real mailbox. |
| Sender name | Your app’s name, e.g. <Your App>. This is what people see in their inbox. |
| Host | smtp.resend.com |
| Port number | 465 |
| Minimum interval per user | 60 seconds is a sensible default. It stops someone spamming one inbox. |
| Username | resend (the word, for everyone) |
| Password | Your Resend API key from 2.3 |
Then select Save changes.
Shortcut: Resend has a Supabase integration that fills in these settings for you. In Resend, open Integrations → Supabase, connect your Supabase account and pick the project and domain. Do 2.2 first either way, because the domain must be verified.
2.5 Raise the Email Rate Limit
With custom SMTP on, Supabase starts you at a conservative limit (30 emails an hour when this guide was written).
- Open Authentication → Rate Limits.
- Set Rate limit for sending emails to what you expect at your busiest hour, with some room to spare.
- Select Save changes.
Remember your Resend plan has its own daily and monthly limits too.
2.6 Make the Email Templates Your Own
Supabase sends a different email for each event. Open Authentication → Emails → Templates to edit them:
| Template | Sent when |
|---|---|
| Confirm sign up | Someone signs up with email and password (when Confirm email is on) |
| Invite user | You invite someone from the dashboard or with inviteUserByEmail() |
| Magic link | Someone calls signInWithOtp(). Used for both magic links and codes |
| Change email address | A signed-in user changes their email |
| Reset password | Someone calls resetPasswordForEmail() |
| Reauthentication | A user confirms a sensitive action, such as changing their password |
Templates are HTML with a few placeholders that Supabase fills in:
| Placeholder | What it becomes |
|---|---|
{{ .ConfirmationURL }} |
The full link to click |
{{ .Token }} |
The 6-digit code |
{{ .TokenHash }} |
A hashed version of the code, for building your own link (see 3.6) |
{{ .SiteURL }} |
Your Site URL from Step 1 |
{{ .RedirectTo }} |
The redirectTo your code passed |
{{ .Email }} |
The user’s email address |
For each template:
- Change the Subject to something clear, e.g.
Your sign-in link for <Your App>. - Edit the Body. Keep the placeholder the email needs (see 3.4 for magic link versus code).
- Select Save changes.
Keep emails short and plain. Big images and lots of links make spam filters suspicious.
Step 3: Set Up Email and Password Sign-In
All the email options live on one page: Authentication → Sign In / Providers.
3.1 Choose Your Sign-Up Settings
At the top of the page, under User Signups:
| Setting | What it does | Recommended |
|---|---|---|
| Allow new users to sign up | Off means only people you invite can get in. | On for public apps, off for internal tools |
| Confirm email | New users must click a link in the Confirm sign up email before they can sign in. | On. It proves the address is real |
| Allow anonymous sign-ins | Lets people use the app before they have an account. | Off unless you need it |
| Allow manual linking | Lets a signed-in user add another sign-in method to their account from your code. | Off unless you need it |
Select Save changes after changing any of them.
3.2 Turn On the Email Provider
- In the provider list, select Email.
- Check Enable Email provider is on. It is by default.
- Set the options below, then select Save.
| Option | What it does | Recommended |
|---|---|---|
| Secure email change | When a user changes their email, both the old and new address must confirm. | On |
| Secure password change | Users must have signed in recently (or confirm by email) to change their password. | On |
| Prevent use of leaked passwords | Rejects passwords found in known data leaks (checked with HaveIBeenPwned). Paid plans only. | On if your plan has it |
| Minimum password length | Shortest password allowed. | 12 (the default is 6) |
| Password requirements | Which kinds of characters a password must include. | Letters and digits at least |
| Email OTP expiration | How long a magic link or code works, in seconds. | 600 to 3600 |
| Email OTP length | How many digits in the code. | 6 |
Setting names can shift a little between dashboard releases. These are the names as of November 2026.
3.3 Sign Up and Sign In with a Password
Set up the client once:
// supabase.jsimport { createClient } from '@supabase/supabase-js'
export const supabase = createClient( // Vite reads these from .env. In Next.js use process.env.NEXT_PUBLIC_SUPABASE_URL and so on. import.meta.env.VITE_SUPABASE_URL, // https://<your-project-ref>.supabase.co import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY, // the publishable (anon) key, safe in the browser)Sign up:
const { data, error } = await supabase.auth.signUp({ email: 'someone@example.com', password: '<a-strong-password>', options: { // Where the "Confirm sign up" link sends them. Must be in Redirect URLs (Step 1). emailRedirectTo: `${window.location.origin}/auth/callback`, },})// With "Confirm email" on, data.session is null until they click the link.// Show a "check your inbox" message here.Sign in:
const { data, error } = await supabase.auth.signInWithPassword({ email: 'someone@example.com', password: '<their-password>',})if (error) console.error(error.message) // e.g. "Invalid login credentials"Sign out:
await supabase.auth.signOut()3.4 Magic Links and One-Time Codes
Magic links and codes use the same function, signInWithOtp(), and the same Magic link email template. What the user receives depends on the template:
| The template contains | The user gets |
|---|---|
{{ .ConfirmationURL }} |
A link to click |
{{ .Token }} |
A code to type |
| Both | Both. Handy when people open the email on a different device |
A template that offers both:
<h2>Sign in to <Your App></h2><p>Your code is <strong>{{ .Token }}</strong>. It expires soon.</p><p>Or <a href="{{ .ConfirmationURL }}">sign in with one click</a>.</p><p>If you didn't ask for this, you can ignore this email.</p>Send the email:
const { error } = await supabase.auth.signInWithOtp({ email: 'someone@example.com', options: { // false = only existing users can sign in this way (no surprise sign-ups) shouldCreateUser: false, // Where the magic link sends them. Must be in Redirect URLs. emailRedirectTo: `${window.location.origin}/auth/callback`, },})If they type a code instead, check it:
const { data, error } = await supabase.auth.verifyOtp({ email: 'someone@example.com', token: '123456', // the code they typed type: 'email',})// data.session is the signed-in sessionSome company email systems “click” every link in an email to scan it for viruses. That uses up the magic link before the user sees it, and they get Email link is invalid or has expired. If your users are on work email, offer the code as well.
3.5 Let Users Reset Their Password
This is two steps: send the email, then save the new password.
-
On your “Forgot password” page, send the Reset password email:
await supabase.auth.resetPasswordForEmail('someone@example.com', {// A page in your app where they pick a new password. Must be in Redirect URLs.redirectTo: `${window.location.origin}/account/update-password`,})// Always show "If that email has an account, we've sent a link",// so people can't use this form to find out who has an account. -
The link signs the user in and sends them to your page. On that page, save the new password:
const { error } = await supabase.auth.updateUser({ password: '<the-new-password>' })
You can also listen for the PASSWORD_RECOVERY event with supabase.auth.onAuthStateChange() to know when someone arrived from a reset link.
3.6 Server-Side Apps (Next.js and @supabase/ssr)
Server-side apps use the PKCE flow (a safer exchange where the browser comes back with a one-time code). Point your email links at a route in your app that checks the hash:
-
In each template, swap
{{ .ConfirmationURL }}for a link to your own route, e.g. in Magic link:<a href="{{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash }}&type=email&next={{ .RedirectTo }}">Sign in</a>Use
type=recoveryin Reset password,type=invitein Invite user andtype=email_changein Change email address. -
Add the route:
// app/auth/confirm/route.js (Next.js App Router)import { NextResponse } from 'next/server'// The server client helper from Supabase's Next.js guide (see References)import { createClient } from '@/utils/supabase/server'export async function GET(request) {const { searchParams, origin } = new URL(request.url)const token_hash = searchParams.get('token_hash')const type = searchParams.get('type') // 'email', 'recovery', 'invite' or 'email_change'const next = searchParams.get('next') ?? '/'if (token_hash && type) {const supabase = await createClient()// Checks the hash and sets the session cookiesconst { error } = await supabase.auth.verifyOtp({ type, token_hash })if (!error) return NextResponse.redirect(new URL(next, origin))}return NextResponse.redirect(new URL('/auth/error', origin))}
A link to your own page is also safer against the link scanners in 3.4, because a scanner’s visit doesn’t sign anyone in until your page runs.
Step 4: Sign In with Google
4.1 Create a Google Cloud Project
- Go to the Google Cloud console.
- Select the project picker at the top, then New project.
- In Project name, type e.g.
<your-app>-auth, then select Create. - Make sure the new project is selected in the project picker.
4.2 Set Up the Consent Screen
The consent screen is the page where Google asks the user “Do you want to sign in to <Your App>?”.
- In the search bar, type
Google Auth Platformand open it. - Select Get started.
- Under App Information, type your App name and pick a User support email. Select Next.
- Under Audience, choose External (anyone with a Google account). Choose Internal only for a Google Workspace app used by your own staff. Select Next.
- Under Contact Information, type an email address Google can reach you on. Select Next.
- Agree to the policy, then select Create.
- Open Branding. Under Authorised domains, add
supabase.coand your own domain. Select Save. - Open Data Access and select Add or remove scopes.
- Tick
openid,.../auth/userinfo.emailand.../auth/userinfo.profile, then select Update and Save.
These three scopes are all Supabase needs. They’re “non-sensitive”, so Google doesn’t need to review your app to use them.
4.3 Create the OAuth Client
- In Google Auth Platform, open Clients.
- Select Create client.
- In Application type, choose Web application.
- In Name, type e.g.
supabase-auth. - Under Authorised JavaScript origins, add your app’s URLs, e.g.
https://app.<your-domain>andhttp://localhost:3000. - Under Authorised redirect URIs, add the Supabase callback:
https://<your-project-ref>.supabase.co/auth/v1/callback. You can copy it from the Google provider page in Supabase (4.4). - Select Create.
- Copy the Client ID (it ends in
.apps.googleusercontent.com) and the Client secret.
Security: Google may only show the client secret once. Copy it now, or download the JSON, and keep it in your password manager. If you lose it, add a new secret to the client and delete the old one.
4.4 Turn On Google in Supabase
- In Supabase, open Authentication → Sign In / Providers.
- Select Google.
- Switch on Enable Sign in with Google.
- In Client IDs, paste the Client ID from 4.3.
- In Client Secret (for OAuth), paste the secret.
- Leave Skip nonce checks and Allow users without an email off.
- Check the Callback URL (for OAuth) matches what you added to Google in 4.3.
- Select Save.
4.5 Add the Google Button
const { error } = await supabase.auth.signInWithOAuth({ provider: 'google', options: { // Where Supabase sends the user afterwards. Must be in Redirect URLs. redirectTo: `${window.location.origin}/auth/callback`, },})The page leaves your app for Google, then comes back to redirectTo signed in. For server-side apps, the callback route is the same one shown in 5.6.
Need to call Google APIs (like Calendar) for the user later? Add queryParams: { access_type: 'offline', prompt: 'consent' } to options to get a Google refresh token, and add those scopes in 4.2. Plain sign-in doesn’t need this.
4.6 Publish the App
While the app’s Publishing status is Testing, only people on its test user list (up to 100) can sign in. Everyone else sees Error 403: access_denied.
- In Google Auth Platform, open Audience.
- To test first, select Add users under Test users and add the Google accounts you’ll test with.
- When you’re ready for real users, select Publish app, then Confirm.
With only the three basic scopes, publishing doesn’t need a Google review. Google may still ask you to verify your branding (app name and logo) before they show on the consent screen. Until then, the screen shows <your-project-ref>.supabase.co. A Supabase custom domain makes it show your own domain instead.
Step 5: Sign In with Microsoft (Azure)
Supabase calls this provider Azure. It uses Microsoft Entra ID (formerly Azure Active Directory), so it works with Microsoft 365 work accounts and, if you want, personal Outlook and Hotmail accounts.
Here’s what you copy between the two dashboards. You’ll do each of these in the steps below.
| Microsoft Entra admin centre (your app registration) | Direction | Supabase (Sign In / Providers → Azure) |
|---|---|---|
| Application (client) ID | Copy to Supabase | Application (client) ID |
| Client secret Value | Copy to Supabase | Secret Value |
| Supported account types | Decides | Azure Tenant URL (see 5.1) |
| Redirect URI | Copy from Supabase | Callback URL (https://<your-project-ref>.supabase.co/auth/v1/callback) |
5.1 Pick Who Can Sign In
This decides the Supported account types in Microsoft and the Azure Tenant URL in Supabase. They must agree.
| Who your users are | Microsoft “Supported account types” | Supabase Azure Tenant URL | Script flag |
|---|---|---|---|
| Only people in your company | Accounts in this organisational directory only | https://login.microsoftonline.com/<your-tenant-id> |
--audience single |
| Staff from any company on Microsoft 365 | Accounts in any organisational directory | https://login.microsoftonline.com/organizations |
--audience multi |
| Work accounts and personal Outlook or Hotmail | Any organisational directory and personal Microsoft accounts | https://login.microsoftonline.com/common |
--audience multi-personal |
Internal tool? Go single tenant. It’s the most locked down: people outside your company can’t even reach the sign-in page for it.
Next, create the app registration either in the portal (5.2) or with the script (5.3). They do the same thing.
5.2 Create the App Registration in the Portal
Register the app
- Go to the Microsoft Entra admin centre.
- Open Identity → Applications → App registrations.
- Select New registration.
- In Name, type something you’ll recognise, e.g.
<your-app>-supabase-auth. - Under Supported account types, pick the option from 5.1.
- Under Redirect URI, choose the platform Web (not SPA), and paste
https://<your-project-ref>.supabase.co/auth/v1/callback. - Select Register.
- On the Overview page, copy the Application (client) ID. For single tenant, also copy the Directory (tenant) ID.
Create a client secret
- Open Certificates & secrets → Client secrets.
- Select New client secret.
- Type a description such as
supabase-auth-2026-11and pick an expiry. 12 months is a sensible default. - Select Add, then copy the Value column straight away.
Copy the Value, not the Secret ID. The Secret ID looks plausible, but Supabase fails with invalid_client if you paste it. The value is only shown once.
Add the email claim
Supabase needs an email address to create the user, and Microsoft doesn’t always send one.
- Open Token configuration.
- Select Add optional claim, then ID.
- Tick email and xms_edov, then select Add.
- If asked, tick Turn on the Microsoft Graph email permission.
xms_edov (“email domain owner verified”) tells Supabase the user’s company really owns their email domain. It stops someone in another tenant from setting an unverified email like ceo@<your-domain> and being matched to your real user.
Check the API permissions
- Open API permissions.
- Check these Microsoft Graph delegated permissions are listed:
openid,email,profile,User.Read. Add any that are missing. - Optional: select Grant admin consent for
<your-tenant>so users aren’t asked to agree on their first sign-in. Some tenants block sign-in until an admin does this.
5.3 Or Create It with the Azure CLI
The script create-azure-app-registration.sh does everything in 5.2 for you, in this order:
- Creates the app registration (or updates it if one with that name exists), with the Supabase callback URL and the email claims.
- Creates the service principal, which is the app’s identity in your tenant.
- Adds the Microsoft Graph permissions
openid,email,profileandUser.Read, and grants admin consent if you pass--admin-consent. - Creates a client secret.
- Prints what to paste into Supabase, and writes it to a
.envfile if you pass--env-file.
-
Log in to the tenant the app should live in:
Terminal window az login --tenant <your-tenant-id># Check you're in the right placeaz account show --query "{tenant:tenantId, user:user.name}" -o table -
Preview what it would do.
--dry-runchanges nothing:Terminal window chmod +x docs/supabase/scripts/create-azure-app-registration.sh./docs/supabase/scripts/create-azure-app-registration.sh \--app-name "<your-app>-supabase-auth" \--project-ref "<your-project-ref>" \--audience single \--extra-redirect "http://127.0.0.1:54321/auth/v1/callback" \--dry-run -
Run it again without
--dry-runto make the changes. Leave out a required flag and the script asks for it.
| Flag | Required | What it does |
|---|---|---|
--app-name |
Yes | Name of the app registration. Re-running with the same name updates it instead of making a second one. |
--project-ref |
Yes | Your Supabase project ref, used to build the callback URL. |
--tenant-id |
Safety check that you’re logged in to the right tenant. Defaults to the current one. | |
--audience |
single (default), multi or multi-personal. See 5.1. |
|
--extra-redirect |
An extra callback URL, e.g. for local development. Repeat the flag for more. | |
--custom-domain |
Adds https://<domain>/auth/v1/callback for a Supabase custom domain. |
|
--secret-years |
How long the secret lasts, in years. Default 1. |
|
--admin-consent |
Grants consent for the whole tenant (needs an admin role). | |
--env-file |
Adds the three values to a file for the Supabase CLI (Step 6). | |
--dry-run |
Shows what it would create or change, and changes nothing. |
At the end it prints something like this:
Paste these into Supabase: Dashboard -> Authentication -> Sign In / Providers -> Azure----------------------------------------------------------------------------- Application (client) ID : <your-client-id> Secret Value : <your-client-secret> Azure Tenant URL : https://login.microsoftonline.com/<your-tenant-id>Security: the secret is printed once. Put it straight into your password manager or Key Vault, and don’t paste the terminal output into tickets or chat.
5.4 Turn On Azure in Supabase
- In Supabase, open Authentication → Sign In / Providers.
- Select Azure.
- Switch on Enable Sign in with Azure.
- In Application (client) ID, paste the client ID.
- In Secret Value, paste the secret value.
- In Azure Tenant URL, paste the URL from the table in 5.1.
- Select Save.
5.5 What Lands in Your Database
After someone signs in, they appear in auth.users, and their Microsoft (or Google) details are in auth.identities. Run this in the SQL Editor:
select u.email, i.provider, -- 'email', 'google' or 'azure' i.identity_data ->> 'full_name' as name, i.identity_data ->> 'custom_claims' as claims, -- Microsoft: includes tid (tenant ID) u.last_sign_in_atfrom auth.users ujoin auth.identities i on i.user_id = u.idorder by u.last_sign_in_at desc;Multi-tenant app? Microsoft’s tenant ID (tid) is in the identity’s custom claims. Use it to match users to the right customer, or to block tenants you don’t serve.
5.6 Add the Microsoft Button
In the browser:
const { error } = await supabase.auth.signInWithOAuth({ provider: 'azure', options: { // Always ask for email, or Supabase may not receive one scopes: 'email', // Where Supabase sends the user afterwards. Must be in Redirect URLs. redirectTo: `${window.location.origin}/auth/callback`, },})For server-side apps (@supabase/ssr), the browser comes back to your app with a ?code=, which you swap for a session. This one route works for Google and Microsoft:
// app/auth/callback/route.js (Next.js App Router)import { NextResponse } from 'next/server'import { createClient } from '@/utils/supabase/server'
export async function GET(request) { const { searchParams, origin } = new URL(request.url) const code = searchParams.get('code') const next = searchParams.get('next') ?? '/'
if (code) { const supabase = await createClient() // Swap the one-time code for a Supabase session (sets the auth cookies) const { error } = await supabase.auth.exchangeCodeForSession(code) if (!error) return NextResponse.redirect(`${origin}${next}`) } return NextResponse.redirect(`${origin}/auth/error`)}Step 6: Local Development with the Supabase CLI
Running Supabase on your machine with supabase start? The local Auth server has its own settings in supabase/config.toml. The dashboard settings don’t apply to it.
-
Add the local callback
http://127.0.0.1:54321/auth/v1/callbackto the Authorised redirect URIs in Google (4.3) and to the redirect URIs in Microsoft (5.2, or the script’s--extra-redirect). -
Put the secrets in
supabase/.env, and addsupabase/.envto.gitignore:Terminal window SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID=<your-google-client-id>SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET=<your-google-client-secret>SUPABASE_AUTH_EXTERNAL_AZURE_CLIENT_ID=<your-azure-client-id>SUPABASE_AUTH_EXTERNAL_AZURE_SECRET=<your-azure-client-secret>SUPABASE_AUTH_EXTERNAL_AZURE_URL=https://login.microsoftonline.com/<your-tenant-id> -
Point
supabase/config.tomlat them:[auth]site_url = "http://localhost:3000"additional_redirect_urls = ["http://localhost:3000/**"][auth.email]enable_signup = trueenable_confirmations = true # same as "Confirm email"otp_length = 6otp_expiry = 3600 # seconds[auth.external.google]enabled = trueclient_id = "env(SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID)"secret = "env(SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET)"redirect_uri = "" # empty = the default local callback[auth.external.azure]enabled = trueclient_id = "env(SUPABASE_AUTH_EXTERNAL_AZURE_CLIENT_ID)"secret = "env(SUPABASE_AUTH_EXTERNAL_AZURE_SECRET)"redirect_uri = ""url = "env(SUPABASE_AUTH_EXTERNAL_AZURE_URL)" -
Restart:
supabase stop && supabase start.
You don’t need Resend locally. The CLI catches every email in a local inbox at http://127.0.0.1:54324, so you can click magic links and read codes without sending anything.
Security
Security: three secrets make this work: the Google client secret, the Microsoft client secret and the Resend API key. Anyone holding one can pretend to be your app to that service. None of them belong in your app’s code or in the browser.
- Secrets: keep each secret in your password manager or vault, and in the Supabase dashboard. Locally they live in
supabase/.env, which must be git-ignored (the Microsoft script sets it tochmod 600). Your app only ever needs the Supabase URL and the publishable key. - Least privilege:
- Resend: use a Sending access key limited to one domain, not Full access.
- Google: ask only for
openid,emailandprofile. - Microsoft: only delegated
openid,email,profileandUser.Read. Creating the app registration needs only the Application Developer role. Use Cloud Application Administrator just for the one-off admin consent. - Supabase: only Owners and Administrators should be able to change Auth settings.
- Narrow audiences: single tenant for internal Microsoft apps. In Enterprise applications → your app → Properties, set Assignment required to Yes to limit sign-in to chosen users or groups. For Google Workspace staff apps, use the Internal audience.
- Email trust: keep Confirm email on, so nobody can sign up as someone else. Keep the Microsoft
xms_edovclaim, and leave Google’s Allow users without an email off. Supabase links sign-ins with the same verified email to one user, so an unverified email could let someone into another person’s account. - Passwords: a minimum length of 12, leaked password protection if your plan has it, and Secure password change on.
- Abuse: keep the email rate limit and the 60 second Minimum interval per user. For public sign-up forms, consider turning on CAPTCHA under Authentication → Attack Protection.
- Email spoofing: SPF, DKIM and DMARC (2.2) stop others sending fake sign-in emails that look like yours. Move DMARC to
p=quarantineonce you’re confident. - Rotate:
- The Microsoft secret expires (12 months by default). To rotate without downtime, re-run the script (it uses
--append, so the old secret keeps working), paste the new value into Supabase, then delete the old secret. - For Google, add a second secret to the OAuth client, paste it into Supabase, then disable and delete the old one.
- For Resend, create a new API key, paste it into SMTP Settings, send a test email, then delete the old key.
- Set calendar reminders a few weeks before each expiry, and rotate straight away if a secret might have leaked.
- The Microsoft secret expires (12 months by default). To rotate without downtime, re-run the script (it uses
- Risks: a leftover or wildcard redirect URI in Google or Microsoft could let an attacker receive sign-in codes. List only your real Supabase callbacks. Keep Supabase Redirect URLs as tight as you can, too.
Verify It Works
Email (Resend):
- In Authentication → Users, select Add user → Send invitation, and invite an address you can read that isn’t a team member.
- The Invite user email arrives from your sender address. That proves custom SMTP works.
- In Resend, open Emails. The email shows as Delivered.
Email and password:
- Sign up in your app with a new address.
- You get the Confirm sign up email. Before clicking it, signing in fails with
Email not confirmed. - Click the link. You land on your app, signed in.
Magic link and code:
- Request a magic link. Click it in the email and check you’re signed in.
- Request again, type the code instead, and check you’re signed in.
Password reset:
- Use “Forgot password” and follow the link.
- Set a new password, sign out, and sign in with it.
Google and Microsoft:
- Select Sign in with Google, pick an account, and check you land back on your app signed in.
- Do the same with Sign in with Microsoft.
- In Authentication → Users, each user shows their provider (email, google or azure).
- Try an account that shouldn’t get in, e.g. a personal Microsoft account on a single-tenant app. Microsoft should refuse it.
Troubleshooting
| Problem or error | Likely cause | Fix |
|---|---|---|
email rate limit exceeded (over_email_send_rate_limit) |
Still on Supabase’s built-in sender, or you hit the limit in Rate Limits. | Set up Resend (Step 2) and raise the limit (2.5). |
email_address_not_authorized |
Built-in sender, which only emails team members. | Set up custom SMTP (Step 2). |
Error sending confirmation email / Error sending magic link email |
Supabase couldn’t send through Resend: wrong API key, domain not verified, or the sender address isn’t on the verified domain. | Check Logs → Auth for the SMTP error, re-check every field in 2.4, and that the domain shows Verified in Resend. |
The <your-domain> domain is not verified (in Resend logs) |
DNS records missing or wrong. | Compare each record with Resend, watching for the domain being added twice (see the warning in 2.2). |
| Emails land in spam | No DMARC record, or the template looks like marketing. | Add the DMARC record, use a plain template, and send from a subdomain. |
For security purposes, you can only request this after 60 seconds |
Minimum interval per user in action. | Wait a minute. It’s working as intended. |
Email link is invalid or has expired (otp_expired) |
The link was already used (often by an email scanner), or it expired. | Request a new one. Offer the code as well (3.4), or use your own confirm route (3.6). |
Email not confirmed |
The user hasn’t clicked the Confirm sign up link. | Ask them to check their inbox, or resend it with supabase.auth.resend({ type: 'signup', email }). |
Invalid login credentials |
Wrong email or password, or the account only signs in with Google or Microsoft. | Check the provider in Authentication → Users. |
Error 400: redirect_uri_mismatch (Google) |
The Supabase callback isn’t in Authorised redirect URIs, or has a typo or trailing slash. | Copy the callback from the Google provider page in Supabase into the OAuth client (4.3). |
Error 403: access_denied / “has not completed the Google verification process” |
The app is in Testing and this account isn’t a test user. | Add them as a test user, or publish the app (4.6). |
AADSTS50011: The redirect URI ... does not match (Microsoft) |
The Microsoft redirect URI isn’t the Supabase callback, or has a typo or trailing slash. | Copy the callback from the Azure provider page into Authentication → Web → Redirect URIs. |
AADSTS7000215: Invalid client secret provided / invalid_client |
You pasted the Secret ID, or the secret expired. | Create a new secret and paste its Value. |
AADSTS50194: Application is not configured as a multi-tenant application |
Tenant URL is common or organizations, but the app is single tenant. |
Use https://login.microsoftonline.com/<your-tenant-id>, or change the app’s audience. |
AADSTS700016: Application ... was not found in the directory |
The user’s tenant can’t use the app. | Check the audience (5.1), or have that tenant’s admin consent. |
AADSTS65001: The user or administrator has not consented / “Need admin approval” |
The tenant blocks users from consenting. | Grant admin consent (5.2, or --admin-consent). |
Error getting user email from external provider |
No email in the token (e.g. a Microsoft user without a mailbox). | Add the email optional claim (5.2) and pass scopes: 'email'. |
| After signing in you land on the production Site URL | redirectTo isn’t on the Redirect URLs list. |
Add it (Step 1). Wildcards like http://localhost:3000/** are fine. |
| Works on the hosted project, not locally | Local Auth reads supabase/config.toml, not the dashboard. |
See Step 6. |
Where to look: Supabase Logs → Auth shows every sign-in attempt and email send. Resend Emails shows delivery for each message. Microsoft Entra Sign-in logs (filter by your app) shows the exact reason for each Microsoft failure.
Cleanup or Rollback
Undo only the parts you need to:
- In Supabase, open Authentication → Sign In / Providers → Google, switch it off, and select Save.
- In Google Cloud, open Google Auth Platform → Clients and delete the client. Or delete the whole project from IAM & Admin → Settings → Shut down.
Microsoft
- In Supabase, switch off Azure the same way.
- In the Entra admin centre, open App registrations → your app and select Delete. Or run
az ad app delete --id <your-client-id>.
Deleted app registrations can be restored for 30 days from App registrations → Deleted applications.
Resend
- In Supabase, open Authentication → Emails → SMTP Settings and switch off Enable custom SMTP. Supabase goes back to its built-in sender, with its limits.
- In Resend, delete the API key, then the domain.
- Remove the Resend DNS records (
send...MX and TXT,resend._domainkey...). Keep the DMARC record if other email uses your domain.
Email and password
- Turn off Allow new users to sign up to stop new accounts, or switch off the Email provider to stop email sign-in altogether.
Local
- Remove the provider blocks from
supabase/config.tomland the values fromsupabase/.env.
Turning a provider off doesn’t delete anyone. Existing users stay in auth.users, but can’t sign in that way until you turn it back on. Remove the sign-in buttons from your app as well.
Dependencies
Other dev-docs guides: none yet. This is the first Supabase guide.
External services:
- Supabase Auth: runs every sign-in flow and stores the users.
- Resend: sends the auth emails over SMTP.
- Your DNS provider: holds the SPF, DKIM and DMARC records Resend needs.
- Google Auth Platform (Google Cloud): signs users in with Google.
- Microsoft Entra ID: signs users in with Microsoft. The
User.Readand other permissions are Microsoft Graph scopes.
Versions
What this guide was written and checked against:
| Tool | Version | Notes |
|---|---|---|
@supabase/supabase-js |
2.x | |
@supabase/ssr |
0.5 or newer | Only for the server-side (Next.js) examples |
| Supabase CLI | 2.0 or newer | Only for local development (Step 6) |
| Azure CLI | 2.37 or newer | Only for the Microsoft script. Needs the Microsoft Graph based az ad commands |
| Resend | Hosted service | Dashboard checked 2026-11-21 |
| Google Auth Platform | Google Cloud console | Checked 2026-11-21 |
References
Checked on 2026-11-21:
- Supabase: Password-based Auth
- Supabase: Passwordless email logins (magic link and OTP)
- Supabase: Email templates
- Supabase: Setting up Server-Side Auth for Next.js (the
@/utils/supabase/serverhelper) - Supabase: Send emails with custom SMTP
- Supabase: Rate limits
- Supabase: Redirect URLs
- Supabase: Login with Google
- Supabase: Login with Azure (Microsoft)
- Supabase: Identity linking
- Resend: Send with Supabase SMTP
- Resend: Managing domains
- Google: Manage OAuth clients
- Google: Setting up OAuth 2.0
- Microsoft: Register an application
- Microsoft: Optional claims reference
- Microsoft: Microsoft Graph permissions reference
- Azure CLI:
az ad app