OAuth 2.0: safely delegate only the access an app needs
Understand OAuthʼs delegated-access flow, how it differs from OIDC, and key checks for PKCE, redirects, least privilege, and tokens.
OAuth 2.0 lets an app receive limited permission to use a protected service on a userʼs behalf without giving the app the userʼs password. It is an authorization framework, not a standard for logging in a user or asserting their identity; OpenID Connect (OIDC) adds that identity layer.
In a typical authorization-code flow, the app sends the user to the authorization server with requested scopes and a registered redirect URI. After authentication and any consent or policy checks, the server returns a short-lived code to that URI. The app exchanges the code at the token endpoint for an access token, then presents the token to the resource server. The resource server checks that the token is valid and intended for the requested resource and action. A mobile/public client uses PKCE to bind the code exchange to the original request.
Use authorization code with PKCE; public clients MUST use PKCE, and confidential clients are RECOMMENDED to use it. Choose S256, compare redirect URIs exactly (with the native localhost port exception), request only needed scopes, restrict tokens to the intended API, and keep them out of URLs and logs. Public-client refresh tokens MUST be sender-constrained or rotated. Avoid the implicit grant; RFC 9700 says clients SHOULD NOT use it. The resource-owner password grant MUST NOT be used because it exposes the userʼs password to the app.
Before approving consent, users should compare requested access with the appʼs purpose. Revoke an untrusted appʼs grant through the serviceʼs connected-app settings. Revocation does not necessarily erase data already copied or end every existing session, so review account activity if compromise is suspected.
References
[IETF RFC 6749: The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html)
[IETF RFC 9700 / BCP 240: Best Current Practice for OAuth 2.0 Security](https://www.rfc-editor.org/rfc/rfc9700.html)
[IETF RFC 7636: Proof Key for Code Exchange (PKCE)](https://www.rfc-editor.org/rfc/rfc7636.html)