Refresh Azure auth token / hook to run a script on 401 http error? Ref #2484

Resolved 💬 6 comments Opened Aug 20, 2025 by santiago-afonso Closed Mar 2, 2026

What feature would you like to see?

The same problem of expiring tokens leading to aborted sessions that was identified in issue #2484 and fixed in commit https://github.com/openai/codex/commit/d1f1e368368622055086d310c2bd78b74f992e0c occurs with Azure bearer tokens. Unlike the OpenAI tokens, in the case of Azure an external script is needed to obtain / refresh the token. If OpenAI / MSFT do not add first party support for Azure to Codex, then perhaps a hook to run a script when an http error 401 takes place would allow us to refresh the tokens. (This would apply to other providers with 1-hr tokens as well.) Otherwise, the 'fix' is quitting codex, refreshing, and reentering, loosing all the conversation history in the process. I am getting GPT-5 to work for close to an hour in general, so this issue is highly problematic.

Are you interested in implementing this feature?

_No response_

Additional information

_No response_

View original on GitHub ↗

This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗