200-901 Question 49
Single answerA developer is creating an application that interacts with a REST API. The API requires clients to authenticate using an API key included in the request header. Which header must the developer include in their HTTP requests to authenticate successfully?
- A
Authorization: Bearer <API_KEY>
- B
Authorization: Basic <API_KEY>
- C
API-Key: <API_KEY>
- D
X-API-Key: <API_KEY>
Show answer and explanation
Correct answer: D
Explanation
When using API keys as an authentication mechanism, the 'X-API-Key' header is a standard and widely accepted method for including the key in HTTP requests. Other options such as 'Authorization: Bearer' or 'Authorization: Basic' are used for token-based and Basic Authentication, respectively, and are not appropriate for API key-based authentication.
- A. Incorrect.
This header format is typically used for OAuth 2.0 Bearer token authentication, not for API key-based authentication.
- B. Incorrect.
This header is used for Basic Authentication, which involves a base64-encoded username and password, not an API key.
- C. Incorrect.
While this header might seem plausible, it is not a standard header used for API key authentication.
- D. Correct.
This is the most commonly used header for API key authentication, where 'X-API-Key' is the standard header key and '<API_KEY>' represents the actual API key.