API API Authentication and Security 1 — Questions and Answers
Question 1: What does JWT stand for?
- Java Web Token
- JSON Web Token (Correct answer)
- JavaScript Widget Token
- Joint Web Transfer
Correct answer: JSON Web Token
JWT stands for JSON Web Token, a compact, URL-safe token format used for securely transmitting information between parties.
Question 2: Which part of a JWT contains the claims about the entity?
- Header
- Payload (Correct answer)
- Signature
- Prefix
Correct answer: Payload
The payload section of a JWT contains the claims, which are statements about the entity (typically the user) and additional metadata.
Question 3: What is OAuth 2.0 primarily used for?
- Encrypting API responses
- Delegated authorization to APIs (Correct answer)
- Hashing passwords
- Compressing request bodies
Correct answer: Delegated authorization to APIs
OAuth 2.0 is an authorization framework that enables applications to obtain limited access to user accounts on third-party services.
Question 4: Which HTTP header is used to send a Bearer token in API requests?
- X-API-Key
- Authorization (Correct answer)
- Token
- Access-Token
Correct answer: Authorization
Bearer tokens are sent in the Authorization header using the format 'Authorization: Bearer <token>'.
Question 5: What is an API key?
- A public RSA key used for encryption
- A unique identifier passed with requests to authenticate the client (Correct answer)
- A secret stored in the server database
- A session cookie
Correct answer: A unique identifier passed with requests to authenticate the client
An API key is a unique identifier passed in requests to authenticate the calling application or user.
Question 6: Which attack involves injecting malicious scripts through API inputs that are reflected in responses?
- SQL Injection
- Cross-Site Scripting (XSS) (Correct answer)
- CSRF
- Man-in-the-Middle
Correct answer: Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS) injects malicious scripts through API inputs that are reflected in web responses and executed in browsers.
What does JWT stand for?