$ man oauth # RFC 6749 · RFC 7636 (PKCE) · OAuth 2.1 draft

OAuth

OAuth 2.0 is a standard for delegated authorization: it lets an application act on your behalf in another service without ever seeing your password. You log in at the service itself, approve a limited scope (“read repositories”, “view calendar”), and the application receives an access token that works only for that scope and only for a while. “Sign in with Google” adds OpenID Connect on top, which also tells the app who you are.

For data engineers, OAuth is how connectors pull from Salesforce, Google Analytics, HubSpot or GitHub, and how services authenticate to each other with the client credentials flow.

The four roles

Resource owner

You

The person whose data is being accessed.

Client

The app

Wants access, for example a reporting tool or an ingestion connector.

Authorization server

Issues tokens

Logs you in and asks for consent. Okta, Entra ID, Auth0, Keycloak, Google.

Resource server

The API

Holds the data and accepts access tokens.

Authorization code flow with PKCE

This is the flow to use for web apps, single-page apps, mobile and CLI tools. PKCE (Proof Key for Code Exchange, “pixie”) was first meant for mobile apps; OAuth 2.1 makes it required for every client.

$ open https://auth.example.com/authorize?...
Authorization code flow with PKCE
BROWSER you APP client AUTH SERVER issues tokens API resource server verifier=random · challenge=SHA256 302 → /authorize GET /authorize?…&code_challenge login + consent 302 → /callback?code=…&state GET /callback?code POST /token code+verifier SHA256(verifier) == challenge? access + refresh token GET /repos Bearer access_token 200 OK
NO.STEPFROMTOTYPEINFO
101appbrowserREDIRECT/authorize?response_type=code&client_id=reports&redirect_uri=…/callback&scope=repo:read&state=xyz&code_challenge=E9Mr…&code_challenge_method=S256
202browserauthLOGINuser authenticates (password, passkey, MFA) and consents
303authbrowserREDIRECT/callback?code=SplxlO…&state=xyz
404appauthTOKENgrant_type=authorization_code, code, redirect_uri, code_verifier=dBjf…
504authappTOKEN{access_token, token_type: Bearer, expires_in: 3600, refresh_token}
605appapiCALLAuthorization: Bearer eyJ… → 200 OK
  1. A reporting app wants to read your repositories. It must never see your password.
  2. The app makes a random code_verifier, keeps it secret, and sends only its hash (code_challenge) when it redirects your browser to the authorization server.
  3. You log in on the authorization server's own page and approve the requested scope, for example repo:read.
  4. The server redirects back to the app with a short-lived authorization code. The app checks that state matches what it sent.
  5. The app exchanges the code plus the original verifier for tokens, over a back channel. A thief who stole only the code cannot pass the hash check.
  6. The app calls the API with the access token. The API checks the token and its scope, not your password.

Which flow when

Flow Use for Status in 2026
Authorization code + PKCE Any app acting for a user The default
Client credentials Service to service, no user (an Airflow DAG calling an internal API) Current
Device authorization TVs, CLIs without a browser (gh auth login, az login --use-device-code) Current
Refresh token Getting a new access token without asking the user again Current; rotate them
Implicit Old SPAs: token returned in the URL Removed in OAuth 2.1, don’t use
Resource owner password App collects your password directly Removed in OAuth 2.1, don’t use

OAuth vs OpenID Connect vs JWT

  • OAuth 2.0 answers “may this app do X?” It gives an access token for an API.
  • OpenID Connect (OIDC) answers “who is this user?” It adds an ID token (always a JWT) and a /userinfo endpoint. Use it for login.
  • JWT is just a token format. Access tokens are often JWTs, but they may also be opaque strings the API checks with the authorization server (token introspection).

Common mistakes

  • Using the access token as proof of login. That’s what the ID token is for. An access token issued to another app could be replayed against yours.
  • Skipping state or PKCE. That opens the door to CSRF and stolen authorization codes.
  • Loose redirect URIs. Register exact URIs. Wildcards let attackers redirect codes to themselves.
  • Asking for broad scopes. Request the minimum (repo:read, not repo). Users and security reviews will thank you.
  • Storing refresh tokens like config. They are long-lived credentials. Keep them in a secrets manager and rotate them.

Learning Resources

See also: JWT, HTTPS.