🍿 @lorenzopant/tmdb

Create Session

Exchange an approved request token for a permanent session ID — step 3 of the v3 session flow.

Exchanges a user-approved request token for a permanent session ID. This is step 3 of the v3 session flow.

The request token must have been approved by the user either by visiting the TMDB authentication URL (from create_request_token()) or by validating it directly via create_session_with_login().

The returned session_id is valid indefinitely until explicitly invalidated via delete_session().

async create_session(body: AuthCreateSessionBody): Promise<AuthCreateSessionResponse>

TMDB Reference: Create Session

Parameters

NameTypeRequiredDescription
request_tokenstringAn approved request token from create_request_token.

Returns

AuthCreateSessionResponse

Errors

HTTPTMDB codeCause
4013Invalid or missing access token.
40133Invalid or unapproved request token.

Example

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

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

// After the user has approved the request token:
const { session_id } = await tmdb.authentication.create_session({
	request_token: "ff5c7eeb5a8870efe3cd7fc5c282cffd26800ecd",
});

console.log(session_id); // "79191836ddaa0da3df76a5ffef6f07ad6ab0c641"

// Use the session_id with account endpoints:
const profile = await tmdb.account.details({ account_id: 123, session_id });

On this page