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
| Name | Type | Required | Description |
|---|---|---|---|
request_token | string | ✅ | The request token that the user has approved at the TMDB website. |
Returns
Errors
| HTTP | TMDB code | Cause |
|---|---|---|
| 401 | 3 | Invalid or missing access token. |
| 401 | 33 | The request token has not been approved or is invalid. |
| 401 | 10 | User 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