Create Request Token
Generate a request token — step 1 of the v4 authentication flow.
Generates a short-lived request token that the user must approve at the TMDB website. This is step 1 of the v4 authentication flow.
After receiving the token, redirect the user to:
https://www.themoviedb.org/auth/access?request_token={request_token}Or with a redirect back to your app after approval:
https://www.themoviedb.org/auth/access?request_token={request_token}&redirect_to=https://yourapp.com/callbackOnce the user approves the token, exchange it for a permanent access token via
create_access_token().
async create_request_token(body?: V4AuthCreateRequestTokenBody): Promise<V4AuthRequestTokenResponse>TMDB Reference: Create Request Token
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
redirect_to | string | ❌ | URL to redirect the user back to after they approve the request token on TMDB. |
Returns
Errors
| HTTP | TMDB code | Cause |
|---|---|---|
| 401 | 3 | Invalid or missing access token. |
Example
import { TMDB } from "@lorenzopant/tmdb";
const tmdb = new TMDB("your-access-token");
const { request_token } = await tmdb.v4.auth.create_request_token({
redirect_to: "https://yourapp.com/callback",
});
const approvalUrl = `https://www.themoviedb.org/auth/access?request_token=${request_token}`;
console.log(approvalUrl);