OAuth and OpenID Connect
Two different questions
OAuth 2.0 delegates access: a calendar client can obtain limited permission to read events from an API. OpenID Connect (OIDC) adds an authentication layer so the client can establish who signed in. An access token is meant for a resource server; an ID token is meant for the client. A refresh token is used with the authorization server to obtain new access tokens when permitted. Do not send an ID token to an API as an access token.
Authorization code flow
In a fictional service, the browser goes from reports.example to login.example; the authorization server authenticates the user and evaluates consent or policy. It returns a short-lived code to the registered callback. The client exchanges that code at the token endpoint, using client authentication when required. PKCE binds the exchange to the initiating client instance: a fresh verifier stays with the client, and its S256 challenge accompanies the authorization request. This is a conceptual sequence, not a live setup.
Redirects and request correlation
Register exact HTTPS callback addresses for the fictional web client, not arbitrary destinations or wildcard paths. For example, https://reports.example/callback is a different address from https://reports.example/other. Use an established client library to bind the response to the initiating browser transaction and implement the required CSRF protection. In OIDC, a nonce sent with the authentication request must match the validated ID token. PKCE, state and nonce have related but distinct roles; none replaces issuer or audience validation.
Worked scope example
Suppose the reports API accepts reports:read, and the client requests only this scope. An approved read request may return report A; editing report A still requires a write permission, and reading another tenant’s report still requires object-level authorization. Keep tokens out of URLs and logs. A client secret cannot be kept confidential in a distributed public client merely by embedding it in the application. Avoid legacy implicit and password grants in new designs; follow RFC 9700 and the chosen client profile.
Practice and review
Draw four boxes: browser, client, authorization server and API. Label who receives the code, ID token and access token. For a read-only report viewer, identify the least privilege scope, the exact callback, the response correlation check and the independent report ownership check. Explain why successful login does not authorize an edit. Review RFC 9700 and OIDC Core before configuring any real provider.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
OAuth and OpenID Connect — knowledge check
Apply federation and token validation principles to fictional scenarios.
What does OAuth delegate?
Who consumes an OIDC ID token?
What does PKCE bind?
Which web redirect is appropriate?
Does reports:read grant editing?