Skip to content

Token Refresh

All API functions (library, wishlist, catalog, verify) automatically refresh credentials before each call when the access token is expired or about to expire. You don’t need to call refresh() manually in normal usage.

The returned credentials object always contains the latest tokens — persist it after each call to avoid unnecessary refreshes.

import { library } from 'audible-api-ts'
// No need to check expiration or call refresh() — it's automatic
const { items, credentials: updatedCredentials } = await library(credentials)
// Persist the updated credentials (they may contain a refreshed token)
saveCredentialsToStorage(updatedCredentials)

If you need explicit control over token refresh (e.g., to refresh on a schedule without making an API call), you can still use refresh() directly:

import { refresh } from 'audible-api-ts'
const updatedCredentials = await refresh(credentials)
// The updated credentials have a new accessToken and expiresAt
console.log('New expiration:', updatedCredentials.expiresAt)

The refreshToken is long-lived and doesn’t expire in normal use.

FieldChanges?
accessTokenYes — new token
expiresAtYes — new expiration
refreshTokenNo
adpTokenNo
devicePrivateKeyNo
serialNo
localeNo