HTTP & APIs Interview Questions: OAuth Basics

Reviewed by Mark Dickie · Last updated

OAuth 2.0 is an authorization framework that lets a client application access a user's resources on another service without the user handing over their password. For interview purposes, you need to know the four core roles (resource owner, client, authorization server, resource server), the main grant types, how access tokens differ from refresh tokens, and the redirect-based flow that ties them together. Interviewers also test whether you understand which grant type fits a given scenario and why the implicit flow has fallen out of favor.

ConceptWhat it meansCommon interview angle
Authorization code grantTwo-step: code then tokenThe default for web apps with a server backend
Client credentials grantApp authenticates as itselfUsed for server-to-server calls, no user involved
Access tokenShort-lived credential for API callsSent in the Authorization header as a Bearer token
Refresh tokenLong-lived credential to obtain new access tokensStored server-side, never sent to the browser
PKCEProof Key for Code ExchangeRequired for SPAs and mobile apps to protect the code exchange

What does an OAuth interview test?

  1. Mapping the four roles to a concrete scenario (e.g., who is the resource owner when a mobile app reads your Google Calendar)
  2. Choosing the correct grant type for a given client type and explaining why
  3. Walking through the authorization code flow step by step, including the redirect
  4. Explaining why access tokens should be short-lived and where to store refresh tokens
  5. Identifying what PKCE protects against and when it is required

How does the authorization code flow work?

The authorization code flow is the grant type interviewers ask about most. The client redirects the user to the authorization server's consent page. After the user approves, the server redirects back to the client with a short-lived authorization code. The client then exchanges that code (plus its own credentials) at the token endpoint for an access token and an optional refresh token. The code itself is single-use and expires in roughly 30–60 seconds, which is why it is safer than returning a token directly in the redirect URL.

Access tokens vs refresh tokens: what is the difference?

Access tokens are short-lived credentials the client sends with each API request, typically in an Authorization: Bearer <token> header. Refresh tokens are longer-lived and exist only to obtain new access tokens without prompting the user again. An access token that is intercepted has a short window of usefulness; a refresh token that is intercepted is more dangerous, so it should live on a server, never in browser localStorage or a cookie readable by JavaScript.

Key facts

  • Tarmac has 35 HTTP & APIs interview questions on this topic, 10 of them on this page, at difficulty 1–5 of 5.
  • Tarmac tracked 4,906 job postings asking for HTTP & APIs in August 2026.
  • Roles asking for HTTP & APIs advertise a median base salary of US$167,500, across 883 job postings as of August 2026.
  • Tarmac last reviewed these HTTP & APIs interview questions on 14 September 2026.

At a glance

Questions10 shown · 35 in the bank
Difficulty1–5 of 5
FormatsTrue / false, Fill in the blank, Flashcard, Multiple choice, Ordering, Short answer, Multiple answer

What you'll review

  1. oauth basics
  2. api auth

Practice questions

Try one before you open the answer. Pick an option and press Check; it's marked on the spot.

HTTP & APIs/api-auth/oauth-basics

In OAuth 2.0, a refresh token can be used directly as a Bearer token to access a protected resource on the resource server.#

Options

Show answer

No, a refresh token cannot be used directly to access a protected resource. Refresh tokens are presented only to the authorization server's token endpoint to obtain a new access token. The resource server only accepts access tokens (typically as a Bearer token in the Authorization header), not refresh tokens.

Why:

Refresh tokens are credentials used exclusively with the authorization server's token endpoint to obtain new access tokens (and optionally new refresh tokens) when the current access token expires. They are never sent to the resource server. Only access tokens are presented to the resource server as Bearer tokens in the Authorization header.

HTTP & APIs/api-auth/oauth-basics

Complete the following sentence about OAuth 2.0 roles:#

Show answer

Complete the following sentence about OAuth 2.0 roles:

The entity that hosts the protected data and accepts access tokens to authorize requests is called the resource server.

Why:

OAuth 2.0 defines four core roles: the Resource Owner (user), the Client (application), the Authorization Server (issues tokens), and the Resource Server (hosts and protects the data). The Resource Server validates incoming access tokens on API calls to decide whether to fulfil the request. Understanding these roles is fundamental to OAuth literacy.

HTTP & APIs/api-auth

What is the OAuth 2.0 client credentials grant, and when do you use it?#

Show answer

A grant where the client authenticates to the token endpoint with its own credentials (client ID + secret, or a certificate) and receives an access token representing itself — there's no resource owner, no browser redirect, and no consent screen. Use it for machine-to-machine calls where a service needs to call another service's API on its own behalf, not a user's — e.g. a nightly batch job or a backend microservice calling another backend API.

Why:

Because there's no user involved, the client credentials grant collapses OAuth's multi-step redirect dance into a single request/response: the client presents its credentials directly and gets a token back. RFC 6749 §4.4 restricts it to confidential clients — ones that can hold a secret, i.e. server-side services, never a browser app or mobile app — and says a refresh token normally shouldn't even be issued, since the client can just re-authenticate with its own credentials to get a new access token whenever it needs one.

HTTP & APIs/api-auth/oauth-basics

Complete the following statements about OAuth 2.0 token types and the state parameter:#

Show answer

Complete the following statements about OAuth 2.0 token types and the state parameter:

  1. An access token is typically short-lived (lasting minutes to hours), while a refresh token is typically long-lived (lasting days to months) and is used to obtain new access tokens without re-involving the user.
  2. The state parameter in the authorization request is an opaque value the client generates and later verifies in the callback response, primarily to prevent CSRF attacks.
Why:

Access tokens are intentionally short-lived to limit the damage window if they are compromised; once expired, the client must use a long-lived refresh token to get a new one without forcing the user to log in again. The state parameter acts as a CSRF mitigation: the client stores it locally (e.g., in session or a cookie), includes it in the authorization request, and then verifies that the value returned in the callback matches—preventing a malicious site from tricking the client into completing an authorization flow it did not initiate.

HTTP & APIs/api-auth/oauth-basics

An OAuth 2.0 authorization server issues tokens with the following JWT payload:#

Options

Show answer

The resource server must reject the token with HTTP 401 and WWW-Authenticate: Bearer error="invalid_token" because the exp claim has elapsed. RFC 7519 §4.1.4 states JWT processors MUST reject tokens where the current time is at or after exp. RFC 6750 §3.1 mandates the 401 + invalid_token response. There is no mandatory default clock-skew tolerance defined by the spec.

Why:

RFC 7519 §4.1.4 mandates that JWT processors MUST reject tokens where the current time is at or after the exp value. RFC 6750 §3.1 specifies that an expired token is an invalid_token error and the resource server MUST respond with HTTP 401 and a WWW-Authenticate header carrying error="invalid_token". The azp claim (authorized party) is checked by the client, not required by the resource server for basic validation. The aud as a URI is perfectly valid per RFC 7519 §4.1.3. RFC 7519 does acknowledge that implementors may allow small clock skew, but it is not a default tolerance, and 'MUST reject' takes precedence — accepting is never the correct answer once past exp.

HTTP & APIs/api-auth/oauth-basics

Place the following steps of the OAuth 2.0 Authorization Code flow with PKCE in the correct chronological order, from the client initiating the flow to it receiving usable tokens:#

Put these in order

Show answer

The correct order is: (A) Generate code_verifier / code_challenge → (E) Redirect user-agent to authorization endpoint with code_challenge → (C) User authenticates and consents; server returns authorization_code → (D) Client POSTs authorization_code + code_verifier to token endpoint → (B) Server validates code_verifier and issues tokens. This sequence is defined by RFC 7636 and ensures the authorization code cannot be replayed by an attacker who lacks the original code_verifier.

Why:

PKCE (RFC 7636) extends the Authorization Code flow: (1) The client first generates the code_verifier and its code_challenge before any network request. (2) The client redirects the user-agent to the authorization endpoint, attaching the code_challenge. (3) The user authenticates and grants consent; the authorization server redirects back with the authorization_code. (4) The client exchanges the authorization_code for tokens at the token endpoint, this time sending the raw code_verifier. (5) The authorization server hashes the code_verifier and compares it to the earlier code_challenge, then issues tokens if they match. This order ensures an intercepted authorization_code is useless without the corresponding code_verifier.

HTTP & APIs/api-auth

Explain how PKCE works mechanically (code_verifier and code_challenge), and specifically what class of attack it defends against, and for which kind of OAuth client.#

Show answer

PKCE protects public clients — apps like SPAs and native/mobile apps that can't safely hold a client_secret — against authorization code interception. Before redirecting the user to the authorization server, the client generates a random code_verifier and derives a code_challenge from it (typically SHA-256, method S256), sending the challenge along with the authorization request. The authorization server stores the challenge against the code it issues. When the client later calls the token endpoint to exchange the code for tokens, it must also send the original code_verifier; the server re-derives the challenge from it and only issues tokens if it matches what was stored. An attacker who intercepts just the redirect-borne authorization code doesn't have the verifier — which never left the legitimate client until the token request — so they can't complete the exchange even with a valid code in hand.

Why:

PKCE (RFC 7636) exists because OAuth 2.0 public clients using the authorization code grant are "susceptible to the authorization code interception attack" — without a client secret to prove identity at the token endpoint, anyone who intercepts the code can redeem it. The verifier/challenge pair acts as a one-time, client-generated substitute for a secret: the challenge (sent up front) is a one-way function of the verifier (sent only at the end), so binding the code to the challenge lets the token endpoint confirm the same client that started the flow is the one finishing it, without ever transmitting a reusable shared secret. This matters most for mobile/native apps, where OS-level redirect interception is a real risk, and for SPAs, whose JS is fully inspectable so no secret is truly private — current OAuth security guidance recommends PKCE for all authorization-code clients, confidential or public, as defense in depth.

HTTP & APIs/api-auth/oauth-basics

A confidential OAuth 2.0 client (Authorization Code flow) holds an expired access token and a valid refresh token. Which of the following correctly describes the complete set of parameters the client must send to obtain a new access token, and to which endpoint?#

Options

Show answer

The client must send grant_type=refresh_token, refresh_token=<token>, client_id, and client_secret to the token endpoint (/token). Per RFC 6749 §6, refresh token requests always go to the token endpoint (never /authorize), must use grant_type=refresh_token, and confidential clients are required to authenticate with their client credentials on every token endpoint call.

Why:

In OAuth 2.0, the authorization server issues both an access token and a refresh token during the Authorization Code flow (when 'offline_access' or similar scope is requested). The access token is short-lived and used to access protected resources. The refresh token is long-lived and is sent back to the token endpoint (not the authorization endpoint) to obtain a new access token without re-prompting the user. Critically, the refresh request must include the client credentials (client_id + client_secret for confidential clients) and the grant type must be 'refresh_token'. The resource server is never involved in token refresh — it only validates access tokens.

HTTP & APIs/api-auth/oauth-basics

Regarding PKCE (RFC 7636) in OAuth 2.0, which of the following statements are correct? (Select ALL that apply.)#

Options

Pick every one that applies.

Show answer

Statements a, b, c, and e are correct. PKCE works by having the client generate a random code_verifier, hash it with SHA-256 and Base64URL-encode it as the code_challenge, which is sent in the authorization request. The authorization server stores this challenge and later verifies the raw code_verifier at the token endpoint. PKCE was designed to stop code interception attacks. OAuth 2.1 recommends PKCE for all clients — but it does NOT replace client_secret for confidential clients (statement d is false).

Why:

PKCE (Proof Key for Code Exchange, RFC 7636) was introduced to protect public clients (e.g., native/mobile apps and SPAs) against authorization code interception attacks. The client generates a cryptographically random code_verifier, hashes it with SHA-256 to produce the code_challenge, and sends the challenge (plus code_challenge_method=S256) in the authorization request. Later, it sends the raw code_verifier with the token request. The authorization server re-hashes the verifier and compares it with the stored challenge — this proves the same client that initiated the flow is redeeming the code, defeating a malicious app that stole the authorization code but doesn't know the verifier. The 'plain' method is discouraged. PKCE does NOT replace client_secret for confidential clients but IS recommended for all clients in OAuth 2.1.

HTTP & APIs/api-auth/oauth-basics

Place the following steps of the OAuth 2.0 Authorization Code flow (RFC 6749 §4.1) in the correct chronological order, from first to last.#

Put these in order

Show answer

The correct order is: (1) Client redirects the user to the authorization endpoint with response_type=code and a state nonce → (2) Authorization server authenticates the user and shows the consent screen → (3) Authorization server redirects back with the authorization code and state → (4) Client validates state then POSTs the code to the token endpoint with client credentials → (5) Authorization server issues the access token → (6) Client calls the resource server using the access token as a Bearer token.

Why:

The correct OAuth 2.0 Authorization Code flow order is: (1) Client sends the user to the authorization endpoint with response_type=code, client_id, redirect_uri, scope, and state. (2) The authorization server authenticates the user and asks for consent. (3) The authorization server redirects back to the client's redirect_uri with the code and state parameters. (4) The client verifies state to prevent CSRF, then POSTs to the token endpoint with grant_type=authorization_code, the code, redirect_uri, client_id, and client_secret. (5) The authorization server validates everything and responds with an access token (and optionally a refresh token). (6) The client uses the access token as a Bearer token to call the resource server. Understanding the precise ordering is critical for security — e.g., swapping steps 3 and 4 or skipping state validation are common vulnerabilities.

Sources

The official documentation these questions are checked against:

Related interview questions

Job market

See http-apis salaries and hiring demand from live job postings.

The other 25 questions

This page shows 10 and marks what you pick. That's as far as a page can go. A free account opens the other 25 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.

Start with this topic

Free · the whole bank · 100 marked answers per 30 days · written feedback on the paid plan

What moved, monthly

One email a month when the bulletin comes out: what moved in the markets we track, and the new question topics we published. Confirm your address to join. Unsubscribe any time.