Create Session (with login)
Validate a request token using TMDB credentials directly — an alternative to the browser redirect flow.
Validates a request token using a TMDB username and password directly, as an alternative to the browser-redirect step in the v3 session flow. Designed for server-side apps or environments without a web view.
This replaces step 2 of the standard browser flow — the returned (validated) request token can then be passed directly to create_session().
Important: Always use HTTPS when calling this endpoint. Prefer the browser-redirect flow when possible to keep user credentials out of your server.
async create_session_with_login(body: AuthCreateSessionWithLoginBody): Promise<AuthRequestTokenResponse>TMDB Reference: Create Session (with login)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
username | string | ✅ | The TMDB account username. |
password | string | ✅ | The TMDB account password. |
request_token | string | ✅ | A request token from create_request_token. |
Returns
AuthRequestTokenResponse — the same shape as create_request_token, but with the token now approved and ready to pass to create_session.
Errors
| HTTP | TMDB code | Cause |
|---|---|---|
| 401 | 3 | Invalid or missing access token. |
| 401 | 30 | Invalid username and/or password. |
| 404 | 34 | Invalid or expired request token. |
Example
import { TMDB } from "@lorenzopant/tmdb";
const tmdb = new TMDB("your-access-token");
// Step 1 — create a request token
const { request_token } = await tmdb.authentication.create_request_token();
// Step 2 (server-side alternative) — validate with credentials
const validated = await tmdb.authentication.create_session_with_login({
username: "johndoe",
password: "secret",
request_token,
});
// Step 3 — exchange the validated token for a session ID
const { session_id } = await tmdb.authentication.create_session({
request_token: validated.request_token,
});