Invalid API key or access token

Hello,
I built a shopify app using the Remix template. i made a custom loader in app._index.tsx and used console.log to get the access token from the session object:

export const loader = async ({ request }: LoaderFunctionArgs) => {
const { admin, session, } = await authenticate.admin(request);
console.log(session);
return null;
}
But when i call the admin API through Postman or other ways (for the same eshop), i get the error “Invalid API key or access token (unrecognized login or wrong password)”. I haven’t reinstalled the app so the access token remains the same, right? (it seems to be an offline access token). here is the output from the consoloe.log above:

Session {
id: ‘offline_niai-gr.myshopify.com’,
shop: ‘niai-gr.myshopify.com’,
state: ‘’,
isOnline: false,
scope: ‘write_products’,
expires: undefined,
accessToken: ‘…’,
onlineAccessInfo: undefined
}

Clarification: I am calling the API using the url https://niai-gr.myshopify.com/admin/api/2025-01/graphql.json and using X-Shopify-Access-Token header for the access token

Hey, were you able to find a solution for this? I am using the offline access token for the store for the X-Shopify-Access-Token header and I’m facing the same issue. Please let me know

Hi @alex94

You’re attempting to use a session token for authenticating against the Admin API.

A session token is not the same as an offline token.

A session token is a JWT that represents a specific short lived session between the merchant and your app.

A session token can be exchanged for an offline token which is long lived and intended to be stored securely in your app’s database and can be used to make Admin API requests.

You can exchange an session token for an offline token with this API endpoint: Exchange a session token for an access token