Short answer
OAuth 2.0 is an authorization framework: it lets an app obtain limited access to a service on a user’s behalf, without ever seeing the user’s password. ‘Sign in with Google’ or GitHub uses OAuth, usually with OpenID Connect on top for identity. In an AI-built app the provider and Supabase do most of the work; the risks sit in redirect URLs, the callback page and what you do with provider tokens.
Ask an AI about this page:ChatGPTClaude
On this page
OAuth 2.0 is an authorization framework that lets an application obtain limited access to a service on behalf of a user, without the user handing over their password. RFC 6749 names four roles: the resource owner (the user), the client (your app), the authorization server that issues tokens, and the resource server that accepts them. The result of a successful flow is an access token with a limited scope and lifetime.
Logging in is a slightly different job. OpenID Connect adds “a simple identity layer on top of the OAuth 2.0 protocol” and an ID token that says who signed in. “Sign in with Google” is OpenID Connect running over OAuth.
OAuth in an AI-built app
When you add Google or GitHub login to a Lovable or Bolt app, Supabase Auth plays the middle role. The button calls supabase.auth.signInWithOAuth({ provider: "google" }), the user approves at Google, Google sends them back to Supabase, and Supabase sends them back to your app with a session, which is a Supabase JWT. Your app never sees a Google password.
The weak spots are in your part of the flow:
- Redirect URLs. The target after login has to match your Site URL or an entry on the Redirect URLs allow list. A broad
**pattern that is handy for development and previews matches far more than your live site. - The callback page. Code that reads
?next=or?redirect=from the URL and navigates there without checking it is an open redirect, and it can carry a fresh session to the wrong place. - Provider tokens. Supabase returns the Google or GitHub token after sign-in. It is not stored or refreshed for you; if your code saves it in a table, that table needs strict RLS.
- The flow type. The implicit flow returns tokens in the URL fragment. The code flow with PKCE returns a one-time code instead.
How to check your app
- In the Supabase dashboard, open Authentication → URL Configuration. The Site URL should be your live domain, and production redirect URLs should be exact paths, not
**patterns. - Open your callback route (often
/auth/callback) and search forsearchParams.get("next"),redirectorreturnTo. Each target must be checked to be a same-origin path before you navigate. - Search for
provider_token. If it is written to the database, check who can read that row. - Check how your Supabase client is created:
flowType: "pkce"or a server-side setup that usesexchangeCodeForSessionmeans the code flow.
How to prevent problems
Use the code flow with PKCE, keep the redirect allow list exact in production, and let your callback only navigate to paths on your own site. The redirect fix is on Open redirect after login, and the wider sign-in setup is in Supabase Auth pitfalls.
Frequently asked questions
Is OAuth an authentication protocol?
Not on its own. RFC 6749 describes delegated access to resources. Logging users in is done with OpenID Connect, an identity layer on top of OAuth 2.0 that adds an ID token. In everyday speech both are called OAuth.
Does Supabase store the Google or GitHub access token for me?
No. Supabase Auth gives you the provider token after sign-in but does not store it in your database and does not refresh it. If you need it on a server, send it to a server you control.
Which OAuth flow should a single-page app use?
The authorization code flow with PKCE. The OAuth security best practice (RFC 9700) says to avoid the implicit grant and requires PKCE for public clients such as browser apps.
Sources
- 1.RFC 6749: The OAuth 2.0 Authorization Framework — IETF
- 2.RFC 9700: Best Current Practice for OAuth 2.0 Security — IETF
- 3.OpenID Connect Core 1.0 — OpenID Foundation
- 4.Social Login — Supabase Docs
- 5.Redirect URLs — Supabase Docs
- 6.PKCE flow — Supabase Docs