🍿 @lorenzopant/tmdb

Create Access Token

Exchange an approved request token for a permanent user access token — step 3 of the v4 authentication flow.

Exchanges a user-approved request token for a permanent user access token and the associated TMDB account ID. This is step 3 of the v4 authentication flow.

Store the returned access_token securely — it is valid indefinitely until explicitly revoked with delete_access_token().

async create_access_token(body: V4AuthCreateAccessTokenBody): Promise<V4AuthAccessTokenResponse>

TMDB Reference: Create Access Token

Parameters

NameTypeRequiredDescription
request_tokenstringThe request token that the user has approved at the TMDB website.

Returns

V4AuthAccessTokenResponse

Errors

HTTPTMDB codeCause
4013Invalid or missing access token.
40133The request token has not been approved or is invalid.
40110User suspended.

Example

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

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

// request_token is obtained from create_request_token() after the user approves it
const { access_token, account_id } = await tmdb.v4.auth.create_access_token({
	request_token: "the-approved-request-token",
});

console.log(account_id); // use this with v4 account endpoints

On this page