InterviewStack.io LogoInterviewStack.io

API Security, Authentication and Authorization Questions

Controlling who can call an API, what they may do, and defending it against abuse. Covers the access-control mechanics: API keys, OAuth 2.0 flows, OpenID Connect, JWT issuance/validation, session vs. token auth, scopes/roles for fine-grained authorization, token lifetime and refresh, mutual TLS, and machine-to-machine vs. user-delegated access. Also covers the adversarial hardening view: input validation, injection and deserialization risks, broken object-level authorization (BOLA), mass assignment, secrets handling, and the OWASP API Security Top 10, plus securing data in transit, preventing enumeration/scraping, and testing APIs for vulnerabilities.

EasyTechnical
55 practiced

Explain the differences between input validation, schema/contract validation (OpenAPI/JSON Schema), and output encoding. Give concrete examples of how each prevents different attack classes such as SQL injection, XSS, and parameter pollution, and list common developer mistakes that lead to validation bypasses.

MediumTechnical
61 practiced

Implement a thread-safe in-memory token-bucket rate limiter in Python. Provide functions:

  • set_rate(key: str, tokens_per_sec: float, burst: int)
  • acquire(key: str) -> bool

Requirements: allow bursts up to 'burst', refill at tokens_per_sec, be concurrency-safe (use threading.Lock), and avoid unbounded memory growth (evict idle keys).

EasyTechnical
62 practiced

Explain the core OAuth 2.0 roles (resource owner, client, authorization server, resource server) and the common flows. For each actor below map the role and justify the flow choice:

  • mobile app
  • backend API
  • third-party web app
  • end user

Also explain when to use Authorization Code (with PKCE), Client Credentials, and when to avoid the Implicit flow.

EasyTechnical
63 practiced

Explain Cross-Origin Resource Sharing (CORS): the headers involved, the browser enforcement model, and what security guarantees CORS does and doesn't actually provide. Then walk through why a wildcard Access-Control-Allow-Origin combined with Access-Control-Allow-Credentials: true is a dangerous configuration, and how you'd safely configure CORS on an API that uses cookies or bearer tokens.

MediumSystem Design
65 practiced

Build an authentication and authorization scheme for a multi-tenant API that supports bearer tokens for user auth and API keys for service-to-service calls. Include per-tenant rate limits, key rotation, revocation, secure key storage, and how to represent tenant scoping in tokens or claims.

Unlock Full Question Bank

Get access to all 20 API Security, Authentication and Authorization interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.