🍿 @lorenzopant/tmdb

Auth

TMDB v4 OAuth-style authentication — create request tokens, exchange them for access tokens, and log users out.

The V4AuthAPI provides the full v4 authentication flow: generating a request token, having the user approve it on the TMDB website, exchanging it for a permanent access token, and revoking it on logout.

import { TMDB } from "@lorenzopant/tmdb";

const tmdb = new TMDB("your-access-token");

// Step 1 — create a request token (optionally pass redirect_to)
const { request_token } = await tmdb.v4.auth.create_request_token({
	redirect_to: "https://yourapp.com/callback",
});

// Step 2 — redirect the user to approve:
// https://www.themoviedb.org/auth/access?request_token={request_token}

// Step 3 — exchange the approved token for a permanent access token
const { access_token, account_id } = await tmdb.v4.auth.create_access_token({ request_token });

// Later — log the user out
await tmdb.v4.auth.delete_access_token({ access_token });

Methods

On this page