I have created a notion public integration to import some data from the telegram bot.
After the initial oauth token exchange, I am able to perform CRUD operation on notion. But after 2 days, I am getting the below error
@notionhq/client warn: request fail { code: 'unauthorized', message: 'API token is invalid.' }
error: message - API token is invalid., stack trace - APIResponseError: API token is invalid.
at buildRequestError (/usr/src/app/node_modules/@notionhq/client/build/src/errors.js:162:16)
at Client.request (/usr/src/app/node_modules/@notionhq/client/build/src/Client.js:304:54)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Is there some token expiry or do I need to make a refresh API token call? I couldn't find this info from the Notion API documentation
Are you storing the code after the OAuth and making the exchange everytime? In that case that will expire. Store the token you receive from the token exchange and use that for making API calls(ie, you don't need to exchange tokens everytime).