When using the authorization header, a call to https://api.themoviedb.org/3/account works (falls back to default id?).
however, a call to https://api.themoviedb.org/3/account?api_key=*** (without authorization header) doesn't work.
Is this by design? any other differences in using the header instead of query parameter?
Δεν μπορείτε να βρείτε κάποια ταινία ή σειρά; Συνδεθείτε για να τη δημιουργήσετε.
Θέλετε να αξιολογήσετε ή να προσθέσετε αυτό το στοιχείο σε μια λίστα;
Δεν είσαι μέλος;
Απάντηση από τον/την Racusthor
στις 2 Μάρτιος 2025 στις 07:17 ΕΊΜΑΙ
does anyone know?
Απάντηση από τον/την Victor Franco
στις 2 Μάρτιος 2025 στις 12:30 ΜΜ
Yes, this is intentional. The MovieDB API has different authentication levels:
1. Using the
api_key
in the URLThe
api_key
works for public requests, such as fetching movies or general information.It does not work for requests that require user authentication.
2. Using the Authorization Header (
Authorization: Bearer <token>
)Required for authenticated requests, like retrieving user-specific data (e.g.,
/account
).The API expects a user authentication token rather than just an API key.
3. Why does
/account
require authentication in the header?The
/account
endpoint returns user-specific data.An
api_key
alone is not enough because it does not identify a specific user.Instead, the API requires an OAuth 2.0 Access Token.
How to fix it?
The user must generate an OAuth 2.0 Access Token and include it in the request header:
This ensures the API knows which user account is making the request.