Recall & Review
beginner
What is API key authentication?
API key authentication is a simple way to control access to an API by requiring a unique key from the client with each request. The server checks this key to allow or deny access.
Click to reveal answer
beginner
How is an API key usually sent in a Flask request?
An API key is commonly sent in the request header, often in the 'Authorization' header or a custom header like 'x-api-key'.
Click to reveal answer
beginner
Why should API keys be kept secret?
API keys grant access to protected resources. If someone else gets your key, they can use your API privileges, which can lead to misuse or data leaks.
Click to reveal answer
intermediate
What is a simple way to check an API key in a Flask route?
You can check the API key by reading it from the request headers and comparing it to a stored valid key before processing the request.
Click to reveal answer
intermediate
What is one limitation of API key authentication?
API key authentication does not verify the identity of the user, only that the key is valid. It also does not encrypt the key, so it should be used with HTTPS.
Click to reveal answer
Where is the API key typically sent in a Flask API request?
✗ Incorrect
API keys are usually sent in the request headers to keep them secure and separate from the URL.
What should a Flask app do if the API key is missing or invalid?
✗ Incorrect
The app should reject requests without a valid API key by returning a 401 Unauthorized status.
Why is HTTPS important when using API key authentication?
✗ Incorrect
HTTPS encrypts data sent between client and server, protecting the API key from being intercepted.
Which Flask object is used to access request headers?
✗ Incorrect
The 'flask.request' object provides access to incoming request data including headers.
What is a common header name used to send an API key?
✗ Incorrect
The 'Authorization' header is commonly used to send API keys or tokens.
Explain how API key authentication works in a Flask application.
Think about the steps from client request to server response.
You got /4 concepts.
Describe best practices for securing API keys in Flask APIs.
Consider how to protect keys from being stolen or misused.
You got /4 concepts.