-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AzureOpenAI authentication issue: new token from azure_ad_token_provider not utilized after expiration #1526
Comments
Thank you for reporting! How were you initializing the library with langchain? Were you using the Azure version? Regardless, this does look like a bug to me as well: openai-python/src/openai/lib/azure.py Lines 268 to 281 in 50371bf
|
Yes, instantiating a
And for
|
@rattrayalex thanks for tagging me! I've opened a PR to fix this in the Azure client: #1531 Also curious, can you expand on what bug you see in the code above? |
this will be fixed in the next release, |
Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
When the initial token expires during a series of retries due to multiple failures, the
azure_ad_token_provider
generates a new token as expected. However, this new token is not utilized byAzureOpenAI
for the remaining retries.The problem originates from the
openai/lib/azure.py
->_prepare_options
function, where theazure_ad_token
is only set toheaders["Authorization"]
during initialization and not whenazure_ad_token
is changed.See
if headers.get("Authorization") is None
below:To Reproduce
The
azure.identity.ClientSecretCredential.get_token
function was utilized as theazure_ad_token_provider
, and theAzureOpenAI.max_retries
was set to1000
. Due to numerous failures and retries, the process exceeded the 60-minute validity period of the token. It is important to note thatLangchain
is being used, rather than directly interfacing withAzureOpenAI
.Code snippets
No response
OS
SuSE12
Python version
Python 3.9.6
Library version
openai v1.27.0
The text was updated successfully, but these errors were encountered: