Explain OAuth and JWT. How would you use them to secure APIs in microservices?
Short answer: OAuth: OAuth is an open standard for access delegation, commonly used to grant limited access to third-party applications without exposing user credentials.
Explain a bit more
OAuth provides a token-based approach to secure APIs. Authorization Flow: OAuth typically involves three parties—Resource Owner (user), Client (application), and Authorization Server (auth provider)—that work together to issue access tokens. JWT: JSON Web Tokens (JWT) are compact, URL-safe tokens used to securely transmit information between parties. JWT tokens are signed and optionally encrypted to protect the integrity and confidentiality of the data. Structure: JWT consists of three parts—Header, Payload, and Signature. How to use them in microservices:
Real-world example (ShopNest)
ShopNest splits Catalog, Cart, Order, and Payment into services so teams can deploy catalog changes without redeploying payments.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png