How "Sign in with ..." works
"Sign in with ..." lets an app learn who you are without ever seeing your password. The idea to keep: the app gets a short-lived code, not a password, and swaps it for tokens.
The short version
The app sends you to the provider's own sign-in page. The provider checks who you are, asks for your consent and sends you back to the app with a one-time authorization code. The app then trades that code for tokens in a direct request to the provider. OAuth 2.0 alone covers access, not identity. The "Sign in with" part is OpenID Connect on top: the app asks for the openid scope and gets an ID token, a JWT that says who signed in.
Step by step
- The app sends the browser to the provider with its client ID, scope (
openidfor sign-in),stateand redirect URI. - The provider signs you in and asks you to agree.
- It redirects the browser to the redirect URI with a one-time code and the same
state. - The app sends the code to the provider's token endpoint with its redirect URI.
- The provider returns an access token and, with OpenID Connect, an ID token.
| Authorization code | Access token | |
|---|---|---|
| Reaches the app through | the browser redirect | a direct request to the provider |
| Lifetime | 10 minutes at most (recommended) | not published |
Why it matters
Your password stays with the provider, which is the upside. The downside is that a sloppy setup can leak the code, so match the redirect URI exactly and use PKCE: RFC 9700 requires it for public clients such as mobile apps.
Sources
- RFC 6749: The OAuth 2.0 Authorization Framework — the authorization code flow, the one-time and short-lived code, the token request
- RFC 7636: Proof Key for Code Exchange (PKCE) — code_verifier and code_challenge, why a stolen code alone is useless
- RFC 9700: OAuth 2.0 Security Best Current Practice — PKCE for public clients, exact redirect URI matching, state
- OpenID Connect Core 1.0 — the identity layer on OAuth 2.0, the
openidscope, the ID token