ExtraBrain Interview Questions

OAuth 2.0 Interview Questions and Answers for 2026

OAuth 2.0 Interview Questions and Answers for 2026 guide cover image for ExtraBrain interview prep

Practice OAuth 2.0 interview questions on flows, tokens, PKCE, security, OIDC, SAML, and real-world implementation trade-offs.

  • OAuth 2.0
  • Security Interviews
  • Backend Interviews
  • SSO

If you are interviewing for backend, platform, DevOps, SRE, security, mobile, or identity engineering roles, OAuth 2.0 is one of the topics you should expect to discuss. It appears in questions about API authorization, third-party integrations, single sign-on, mobile login, service-to-service access, and secure token handling.

A strong OAuth 2.0 answer does more than define the protocol. It shows that you can choose the right flow, explain the security trade-offs, protect tokens, validate redirect URIs, and reason about real production failure modes.

This guide rewrites the core OAuth 2.0 interview topic into a practical ExtraBrain-style prep article. Use it to practice clear answers, rehearse follow-up questions, and turn abstract identity vocabulary into interview-ready explanations.

ExtraBrain can help you practice these answers in mock interviews, review transcripts after a session, and organize your own examples from previous projects. Use any AI interview assistant only where interview, employer, school, workplace, meeting, and platform rules allow AI assistance, transcription, screenshots, or notes.

What OAuth 2.0 Is

OAuth 2.0 is an authorization framework described in RFC 6749. It lets a client application obtain limited access to protected resources without asking the resource owner to share their password with that client.

Instead of giving a third-party app a password, the resource owner authorizes a specific level of access. The authorization server issues an access token. The client uses that access token to call a resource server. The resource server validates the token and grants only the permissions represented by the token and its scopes.

OAuth 2.0 is designed for HTTP-based systems. It is not backward compatible with OAuth 1.0. In modern systems, it is commonly used for delegated API access, social login flows combined with OpenID Connect, enterprise integrations, mobile apps, and machine-to-machine authorization.

The Four Core OAuth 2.0 Roles

RoleInterview explanationExample
Resource ownerThe person or entity that owns the protected data.A user who owns calendar, profile, or health data.
ClientThe application requesting access to protected resources.A mobile app, web app, CLI, or backend service.
Authorization serverThe system that authenticates the resource owner, collects consent, and issues tokens.An identity provider or OAuth provider.
Resource serverThe API or service that hosts protected resources and validates access tokens.A calendar API, payments API, or internal service API.

A Simple OAuth 2.0 Example

Imagine a scheduling app that wants to read a user’s calendar. The app redirects the user to the authorization server. The user signs in and grants a limited calendar-read scope. The authorization server redirects back with an authorization code. The app exchanges that code for an access token. The app then calls the calendar API with the access token instead of ever seeing the user’s password.

That example is useful in interviews because it explains both the happy path and the security motivation. OAuth 2.0 is not just a login button. It is a way to delegate limited access safely.

Why Interviewers Ask OAuth 2.0 Questions

Interviewers ask OAuth 2.0 questions because identity and authorization bugs can create severe security problems. A candidate who can explain OAuth 2.0 clearly is more likely to build safe integrations, protect user data, and avoid insecure shortcuts.

They usually want to know whether you can:

  • Explain the difference between authentication and authorization.
  • Choose the right OAuth 2.0 flow for a web app, SPA, mobile app, device, or backend service.
  • Explain access tokens, refresh tokens, scopes, redirect URIs, and consent.
  • Identify security risks such as token theft, CSRF, open redirects, and insecure storage.
  • Explain why the implicit flow and Resource Owner Password Credentials flow are discouraged for new systems.
  • Use PKCE correctly for public clients.
  • Compare OAuth 2.0 with OpenID Connect and SAML.

A good interview answer usually follows this pattern:

  1. Start with the principle.
  2. Name the correct flow or control.
  3. Explain why it is safer.
  4. Give a production example.
  5. Mention trade-offs and failure cases.

OAuth 2.0 Flows Interview Questions

OAuth 2.0 flow questions test whether you can map a product scenario to the correct grant type. Do not answer by listing every flow from memory only. Answer by explaining which client type you have, where tokens are exchanged, and which secrets can be stored safely.

FlowBest-fit scenarioInterview key point
Authorization Code FlowServer-rendered web apps and confidential clientsAccess token is exchanged server-to-server.
Authorization Code Flow with PKCEMobile apps, SPAs, desktop apps, and public clientsProtects the code exchange when no client secret can be safely stored.
Client Credentials FlowMachine-to-machine accessNo user is involved, so scopes represent service permissions.
Device Authorization FlowTVs, CLIs, consoles, and input-limited devicesUser authorizes on a separate device.
Implicit FlowLegacy browser appsDiscouraged because tokens are exposed in the browser.
Resource Owner Password CredentialsLegacy high-trust casesDiscouraged because the client handles the user’s password.

Question: Explain the Authorization Code Grant and when you would use PKCE.

The Authorization Code Grant is the standard OAuth 2.0 flow for getting tokens without exposing them directly in the browser. The client first redirects the user to the authorization server. After the user authenticates and grants consent, the authorization server returns an authorization code. The client then exchanges that code for tokens through a back-channel token endpoint.

For confidential clients, such as a traditional web application with a secure backend, the client can authenticate with a client secret during the code exchange. For public clients, such as mobile apps, SPAs, and desktop apps, the client cannot safely keep a secret. That is where PKCE is used.

PKCE adds a one-time code verifier and code challenge. The client sends the code challenge during the authorization request and later sends the code verifier during the token exchange. If an attacker intercepts the authorization code but does not have the verifier, the attacker cannot redeem the code for tokens.

A strong interview answer is that Authorization Code with PKCE is the modern default for public clients, and it is also increasingly used as a defense-in-depth measure for other clients.

Question: What is the difference between Authorization Code Flow and Implicit Flow?

The main difference is where the access token is returned. In the Authorization Code Flow, the browser receives only an authorization code, and the access token is obtained through a token endpoint exchange. In the Implicit Flow, the access token is returned directly to the browser, usually in the redirect URI fragment.

That design made the Implicit Flow attractive for older browser-only apps, but it also exposed tokens to browser history, scripts, extensions, logs, and other client-side risks. Modern guidance is to avoid the Implicit Flow for new applications and use Authorization Code with PKCE instead.

A concise answer is: Authorization Code Flow keeps token issuance behind a safer exchange, while Implicit Flow exposes the token too early and is now considered a legacy pattern.

Question: When should you use Client Credentials Flow?

Use Client Credentials Flow for machine-to-machine authorization where no human user is directly involved. For example, a billing service might call an internal reporting API, or a deployment service might call a metadata service.

The client authenticates directly with the authorization server and receives an access token representing the client itself. Scopes and policies should be narrow because there is no user consent screen to limit the action at runtime.

A good answer should mention that Client Credentials Flow is backend-only. It should not be used from a browser, mobile app, or any environment where the client secret cannot be protected.

Question: What is Device Authorization Flow?

Device Authorization Flow is used for devices that have limited input capability, such as TVs, command-line tools, smart appliances, or consoles. The device asks the authorization server for a device code and user code. The user opens a verification URL on another device, enters the code, signs in, and approves access. The original device polls the authorization server until authorization is complete.

This is safer and more usable than forcing a user to type a long password on a constrained device. In interviews, emphasize that the flow separates the device from the user’s full credential entry.

OAuth 2.0 Token Interview Questions

Token questions are common because token design creates most of the day-to-day security trade-offs in OAuth 2.0 systems. You should be ready to discuss access tokens, refresh tokens, bearer tokens, sender-constrained tokens, JWTs, opaque tokens, expiration, storage, rotation, and revocation.

Question: What is the difference between an access token and a refresh token?

An access token is used to access protected resources. It is usually short-lived because it is sent to APIs and may be exposed through network, logging, or client-side mistakes.

A refresh token is used to obtain a new access token after the current access token expires. It is usually longer-lived and must be stored more carefully. Refresh tokens should be rotated, protected, and revoked when suspicious behavior is detected.

The interview-friendly summary is that an access token is for API access, while a refresh token is for maintaining a session without forcing the user to re-authenticate constantly. Short-lived access tokens reduce blast radius, and refresh tokens preserve user experience.

Question: What is a bearer token?

A bearer token is a token that grants access to whoever presents it. The resource server does not require proof that the presenter is the original legitimate holder beyond possession of the token.

That makes bearer tokens simple, but it also means token theft is serious. If an attacker steals a bearer token before it expires, the attacker may be able to call the API as the token holder.

In an interview, pair the definition with mitigations. Use HTTPS, short expirations, secure storage, narrow scopes, refresh token rotation, and strong monitoring. For higher-security systems, mention sender-constrained tokens or mutual TLS as stronger patterns.

Question: Should access tokens be JWTs or opaque tokens?

Both designs are valid. A JWT access token contains signed claims that a resource server can validate without calling the authorization server on every request. This can improve performance and reduce coupling, but it makes immediate revocation harder because the token remains valid until it expires unless the resource server checks a revocation list or introspection service.

An opaque token is a random-looking reference value. The resource server usually validates it by calling an introspection endpoint or by using shared infrastructure. This centralizes control and can make revocation easier, but it adds latency and availability dependency.

A strong answer compares trade-offs rather than claiming one is always better. JWTs are useful for distributed validation and short lifetimes. Opaque tokens are useful when central control, privacy, and immediate revocation matter more.

Question: How do you securely store tokens in a single-page app?

The safest answer is to avoid storing long-lived tokens directly in browser-accessible storage. Do not store tokens in localStorage or sessionStorage when you can avoid it because cross-site scripting can expose them.

A common production pattern is a Backend for Frontend. The SPA completes Authorization Code with PKCE through a backend component. The backend stores or manages tokens server-side and gives the browser a secure HttpOnly, Secure, and SameSite cookie. Because JavaScript cannot read an HttpOnly cookie, this reduces token theft risk from XSS.

If you must build a pure SPA, use Authorization Code with PKCE, keep tokens short-lived, minimize scopes, avoid persistent browser storage where possible, and invest heavily in XSS prevention.

Question: How do you store tokens in a mobile app?

In a mobile app, store sensitive tokens in platform-provided secure storage. On iOS, use Keychain. On Android, use Android Keystore-backed secure storage patterns.

Use Authorization Code with PKCE because mobile apps are public clients and cannot protect a client secret. Keep access tokens short-lived and in memory when possible. Store refresh tokens only in secure storage, rotate them, and revoke them on logout or suspicious activity.

This answer shows that you understand both OAuth protocol design and the realities of device security.

OAuth 2.0 Security Interview Questions

Security questions are where candidates can stand out. Interviewers want to know whether you can reason about attacks, not just name protocol components.

Question: How do you prevent CSRF in OAuth 2.0 flows?

Use the state parameter. Before redirecting the user to the authorization server, generate a cryptographically random value and bind it to the user’s session. Include that value in the authorization request. When the user returns to the redirect URI, compare the returned state with the stored value. Reject the response if the values do not match.

This prevents an attacker from tricking the client into accepting an authorization response that did not originate from the legitimate user’s flow. In OpenID Connect flows, a nonce is also used to bind identity tokens to the authentication request.

Question: Why must redirect URIs be validated exactly?

Redirect URIs determine where authorization codes or tokens are sent after user approval. If an authorization server accepts loose, wildcard, or attacker-controlled redirect URIs, an attacker may be able to steal an authorization code or token.

The best practice is to pre-register redirect URIs and require exact matching. Avoid open redirects in the client application because an allowed redirect URI that forwards to an attacker-controlled URL can still leak the code.

A strong answer says that redirect URI validation protects the handoff point in the OAuth flow. It is one of the most important controls in the protocol.

Question: What are the risks of the Implicit Flow?

The Implicit Flow returns an access token directly to the browser. That token may be exposed through browser history, malicious scripts, extensions, logs, referrers, or other client-side leakage points. It also does not support the same secure back-channel exchange pattern used by Authorization Code Flow.

For modern applications, use Authorization Code with PKCE instead. That keeps the token exchange safer and reduces the chance that an intercepted authorization response can be redeemed by an attacker.

Question: How do you reduce token theft risk?

Use HTTPS everywhere. Keep access tokens short-lived. Use refresh token rotation. Store tokens in secure storage rather than browser-accessible storage. Use narrow scopes and least privilege. Validate audience, issuer, signature, expiration, and scopes at the resource server. Use sender-constrained tokens for higher-risk systems. Monitor anomalous token use and revoke compromised sessions quickly.

This is a good place to show practical maturity. Token security is not one setting. It is a layered design.

Question: How do you revoke a JWT access token?

JWT access tokens are often stateless, which means a resource server can validate them locally until they expire. That makes immediate revocation harder.

The first control is short expiration. If access tokens expire in minutes, the damage window is smaller. The second control is revoking the refresh token so the attacker cannot get new access tokens. The third option is a server-side denylist keyed by token ID, user session ID, or another unique claim. The resource server checks that denylist before accepting the JWT.

The trade-off is that denylist checks reintroduce server-side state and operational complexity. A strong answer explains that you choose the revocation strategy based on security requirements, latency, and scale.

OAuth 2.0 Implementation Interview Questions

Implementation questions test whether you can turn protocol knowledge into production decisions. They often reveal whether a candidate has actually built identity flows or only memorized terms.

Question: What would your OAuth 2.0 implementation checklist include?

I would start by registering the client and allowed redirect URIs with the authorization server. I would use Authorization Code with PKCE for public clients and confidential-client authentication for secure backends. I would request only the scopes needed for the feature. I would validate state, issuer, audience, signature, expiration, and scopes. I would store tokens securely, rotate refresh tokens, and revoke sessions on logout. I would log security events without logging token values. I would test error handling for denied consent, expired codes, replayed codes, mismatched redirect URIs, and token refresh failures.

This kind of checklist answer works well because it moves from design to implementation details.

Question: How do scopes work?

Scopes define the permissions requested by the client and granted by the authorization server. For example, a client might request calendar.read to read calendar events but not calendar.write to create or modify them.

Scopes support least privilege. They also make consent screens understandable because the user can see what the app is asking to do. The resource server should check scopes before allowing a protected action.

In interviews, explain that scopes are not a substitute for full authorization logic. They are one layer in the permission model. The API may still need to check tenant, user, object-level, and role-based permissions.

Question: What happens if an authorization code is intercepted?

Without PKCE, an attacker who intercepts an authorization code might be able to exchange it for tokens if the attacker can satisfy the client authentication requirements. With PKCE, the attacker also needs the original code verifier. Because the verifier was generated by the legitimate client and not sent in the initial redirect, interception of the code alone is not enough.

A strong answer also mentions that authorization codes should be short-lived and single-use. The token endpoint should reject reused, expired, or mismatched codes.

Question: How would you debug an OAuth login failure?

First, identify where the flow fails. Check whether the authorization request is formed correctly. Verify client ID, redirect URI, response type, scopes, state, and PKCE parameters. Then check the callback. Validate that the authorization server returned a code, not an error such as access_denied or invalid_scope. Then check the token exchange. Look for invalid client authentication, mismatched redirect URI, expired code, reused code, or wrong code verifier. Finally, check resource server calls for invalid audience, missing scopes, expired token, or clock skew.

A practical answer should also mention safe logging. Log correlation IDs and error codes, but never log raw access tokens, refresh tokens, client secrets, or authorization codes.

Question: What is the difference between OAuth 2.0 and SAML?

OAuth 2.0 is primarily about authorization. It answers the question, “What can this client access on behalf of the resource owner?”

SAML is primarily used for federated authentication and enterprise single sign-on. It answers the question, “Who is this user, according to a trusted identity provider?”

A useful analogy is that OAuth is like a delegated access pass for a specific set of actions, while SAML is like a signed identity assertion. In modern systems, OAuth 2.0 is often paired with OpenID Connect for authentication, while SAML remains common in enterprise SSO environments.

Advanced OAuth 2.0 Interview Questions

Advanced questions usually test whether you understand current security guidance and can discuss evolving standards.

Question: What is the relationship between OAuth 2.0 and OpenID Connect?

OAuth 2.0 is an authorization framework. OpenID Connect is an identity layer built on top of OAuth 2.0.

OAuth 2.0 answers what a client can access. OpenID Connect answers who the user is. OIDC adds an ID token, standardized user identity claims, and discovery metadata.

In practice, when users click a modern “sign in with” button, the system often uses OIDC for authentication and OAuth 2.0 access tokens for API authorization.

Question: Why does PKCE make Authorization Code Flow safer for SPAs?

SPAs cannot protect a client secret because their code runs in the user’s browser. PKCE replaces the need for a static secret with a one-time proof.

The SPA creates a random code_verifier and derives a code_challenge from it. The challenge is sent in the authorization request. The verifier is sent only during the token exchange. The authorization server checks that they match.

If an attacker steals the authorization code but does not have the verifier, the code is not useful. That is why Authorization Code with PKCE is the modern answer for browser-based public clients.

Question: What changes does OAuth 2.1 bring?

OAuth 2.1 consolidates modern OAuth security guidance into a cleaner specification direction. The key interview points are that the Implicit Grant is removed, the Resource Owner Password Credentials Grant is removed, PKCE is required for Authorization Code flows, and redirect URI matching becomes stricter.

You do not need to recite every draft detail in an interview. What matters is that you understand the direction: remove insecure legacy flows, make PKCE the default, and tighten redirect handling.

Question: How do you handle multi-tenant OAuth integrations?

First, model tenant boundaries explicitly. A token should not give access across tenants unless that is intentionally allowed. Validate the issuer, audience, tenant identifier, scopes, and user identity claims. Map external identities to internal accounts carefully.

Second, treat consent and admin approval as part of the product design. Some integrations require a user to grant access only to their own resources. Others require a tenant admin to approve organization-wide access.

Third, test failure cases. Check what happens when a tenant disconnects an integration, a refresh token is revoked, a user loses permission, or an admin changes policy.

Question: How would you design logout for an OAuth-based app?

Logout has several layers. Delete the local application session. Revoke refresh tokens where supported. Clear secure cookies or local secure storage. Optionally redirect to the identity provider’s logout endpoint if the product requires federated logout.

Do not assume that deleting the local session automatically logs the user out of the identity provider. Also do not assume that logging out of the identity provider automatically revokes every access token already issued to every client. Explain these boundaries clearly in interviews.

How to Answer OAuth 2.0 Interview Questions Well

Use a Repeatable Answer Structure

A strong structure is definition, scenario, design choice, security trade-off, and example. For example, if asked about PKCE, define it, name the public-client scenario, explain the code verifier and code challenge, describe what attack it blocks, and then give a mobile or SPA example.

This prevents vague answers. It also gives the interviewer natural places to ask follow-up questions.

Ask Clarifying Questions

For system design or implementation questions, ask what kind of client you are building. A server-side web app, SPA, mobile app, desktop app, CLI, and backend service have different security assumptions.

Ask whether the system needs user consent, enterprise admin consent, SSO, offline access, mobile support, or machine-to-machine access. Those details determine the right OAuth flow and token storage strategy.

Mention Security Without Fearmongering

Interviewers want practical security judgment. Do not simply say “never do X” without explaining context. Instead, say which patterns are discouraged for new systems, what modern replacement you would use, and what migration path you would consider for legacy systems.

For example, a mature answer says that the Implicit Flow is legacy and should be replaced by Authorization Code with PKCE for new SPAs. It also acknowledges that existing systems may need staged migration, telemetry, and compatibility planning.

Practice With Your Own Project Examples

Prepare two or three examples from your own experience. One could be a user-facing login flow. One could be a machine-to-machine integration. One could be an incident or bug involving token expiry, redirect URI mismatch, or scope handling.

ExtraBrain can help you turn those examples into concise practice answers after a mock interview or technical prep session. Because ExtraBrain is a local-first Mac desktop AI interview assistant and meeting copilot, it can help you review transcripts, outline technical answers, and keep your examples organized when configured according to your privacy preferences.

Common Mistakes to Avoid

  1. Saying OAuth 2.0 is authentication without mentioning authorization.
  2. Ignoring OpenID Connect when the question is really about login identity.
  3. Choosing Implicit Flow for a new SPA instead of Authorization Code with PKCE.
  4. Storing tokens in localStorage without discussing XSS risk.
  5. Forgetting to validate state in authorization responses.
  6. Allowing wildcard redirect URIs without explaining the risk.
  7. Treating scopes as the entire authorization model.
  8. Logging raw tokens, authorization codes, or client secrets.
  9. Using long-lived access tokens without a clear reason.
  10. Giving a generic answer without mapping it to the client type.

Quick Practice Questions

Use these prompts to test yourself before an interview. Try answering each one in under two minutes, then refine the answer with a concrete example.

  • What problem does OAuth 2.0 solve?
  • What are the four OAuth 2.0 roles?
  • Why is Authorization Code with PKCE recommended for public clients?
  • What is the difference between an access token and a refresh token?
  • Where should a mobile app store refresh tokens?
  • Why is localStorage risky for token storage?
  • How does the state parameter reduce CSRF risk?
  • Why are exact redirect URI matches important?
  • When would you use Client Credentials Flow?
  • What is the difference between OAuth 2.0 and OpenID Connect?
  • What is the difference between OAuth 2.0 and SAML?
  • How would you revoke a JWT access token?
  • What OAuth 2.1 changes should engineers know?
  • How would you debug an invalid_grant error?
  • How would you design OAuth for a multi-tenant SaaS integration?

FAQ

Besides Authorization Code Grant, which grant types should I avoid for new applications?

Avoid the Implicit Grant for new browser-based applications. Use Authorization Code with PKCE instead.

Avoid the Resource Owner Password Credentials Grant for new applications. It requires the client to collect the user’s password, which breaks the core OAuth goal of avoiding password sharing with third-party clients.

For modern systems, choose Authorization Code with PKCE for user-facing public clients, standard Authorization Code for secure confidential clients, Client Credentials for backend service access, and Device Authorization Flow for input-limited devices.

Is OAuth 2.0 the same as login?

No. OAuth 2.0 is about delegated authorization. It tells a resource server what a client can access.

Login is about authentication. It tells an application who the user is. OpenID Connect builds on OAuth 2.0 to provide that identity layer through ID tokens and standardized identity claims.

Why is PKCE important if I already use HTTPS?

HTTPS protects the network channel, but it does not solve every authorization-code interception scenario. PKCE protects the token exchange by requiring the client to prove that it created the original authorization request.

If the authorization code is intercepted, the attacker still needs the code verifier. Without the verifier, the token endpoint rejects the exchange.

Should refresh tokens be sent to resource servers?

No. Refresh tokens should be sent only to the authorization server’s token endpoint to obtain new access tokens. Resource servers should receive access tokens, not refresh tokens.

This separation limits exposure. A refresh token is more sensitive because it can often be used to obtain many future access tokens.

What should I say if the interviewer asks for OAuth 2.0 best practices?

Give a layered answer. Use Authorization Code with PKCE for public clients. Use HTTPS everywhere. Validate redirect URIs exactly. Validate state. Use short-lived access tokens. Rotate refresh tokens. Store tokens securely. Request narrow scopes. Validate issuer, audience, signature, expiration, and scopes. Avoid logging secrets or tokens. Monitor suspicious token use and revoke sessions when needed.

How can ExtraBrain help me prepare for OAuth 2.0 interviews?

ExtraBrain can help you practice OAuth 2.0 explanations, rehearse follow-up questions, and review your interview-prep sessions afterward. It is a free, local-first Mac desktop AI interview assistant and meeting copilot with live transcription, screen-aware context, local Gemma 4 where installed and compatible, bring-your-own AI providers, and privacy controls.

Use ExtraBrain responsibly and only where the rules of your interview, employer, school, workplace, meeting, or platform allow AI assistance, transcription, screenshots, or notes.