Error 401 when using REST Admin API

I am creating a shopify app using remix, it will have the function of displaying a list of all articles. However, when I use the function mentioned in the documentation: https://shopify.dev/docs/api/admin-rest/2024-04/resources/blog#get-blogs

await admin.rest.resources.Blog.all({
   session: session,
});

It will display a 401 Unauthorized error on the first load, after installing the app, and the error disappears if the app is reloaded. I really don’t know what to do to fix the error, hope someone will help me.