OIDC Refresh

Does OIDC refresh periodically during production? For every refresh, does it store the latest token in the environment variable?

I have had previous issues where it would pass ~9 hours and then stop working, and I would have to manually redeploy it with

‘vercel --prod’

Any alternative?

OIDC tokens are created on-request if they’ve expired, which should be every 45 minutes

Are you working with the tokens manually anywhere that they may be stored? What error do you see that you’re fixing with a redeploy?

Hi Jacob! My tokens are currently stored in my env variables. No error currently but the one that I encountered was the following:

AI Gateway error response: {"error":{"message":"Error verifying OIDC token\nThe AI Gateway OIDC authentication token is expected to be provided via the 'VERCEL_OIDC_TOKEN' environment variable. It expires every 12 hours.\n- make sure your Vercel project settings have OIDC enabled (already on for new projects by default)\n- if you're running locally with 'vercel dev' the token is automatically obtained and refreshed for you\n- if you're running locally with your own dev server script you can fetch/update the token by running 'vercel env pull'\n- in production or preview the token is automatically obtained and refreshed for you","type":"authentication_error"}}
AI Gateway error: Error: AI Gateway API call failed: Unauthorized

12 hours later, running into this issue again, should I not have the token stored manually anymore? Unsure if im missing something in the docs.