Skip to content
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

openai.AuthenticationError: Error code: 401 - {'statusCode': 401, 'message': 'Unauthorized. Access token is missing, invalid, audience is incorrect (https://cognitiveservices.azure.com), or have expired.'} #2219

Open
mdvohra opened this issue Dec 10, 2024 · 1 comment

Comments

@mdvohra
Copy link

mdvohra commented Dec 10, 2024

File "/usr/local/lib/python3.11/site-packages/quart/app.py", line 1439, in full_dispatch_request
result = await self.dispatch_request(request_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/quart/app.py", line 1535, in dispatch_request
return await self.ensure_async(handler)(**request_.view_args) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/decorators.py", line 56, in auth_handler
return await route_fn(auth_claims, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/app.py", line 374, in upload
await ingester.add_file(File(content=file_io, acls={"oids": [user_oid]}, url=file_client.url))
File "/app/prepdocslib/filestrategy.py", line 127, in add_file
await self.search_manager.update_content(sections, url=file.url)
File "/app/prepdocslib/searchmanager.py", line 288, in update_content
embeddings = await self.embeddings.create_embeddings(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/prepdocslib/embeddings.py", line 149, in create_embeddings
return await self.create_embedding_batch(texts, dimensions_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/prepdocslib/embeddings.py", line 105, in create_embedding_batch
async for attempt in AsyncRetrying(
File "/usr/local/lib/python3.11/site-packages/tenacity/asyncio/init.py", line 166, in anext
do = await self.iter(retry_state=self._retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/tenacity/asyncio/init.py", line 153, in iter
result = await action(retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/tenacity/_utils.py", line 99, in inner
return call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/tenacity/init.py", line 398, in
self._add_action_func(lambda rs: rs.outcome.result())
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/app/prepdocslib/embeddings.py", line 112, in create_embedding_batch
emb_response = await client.embeddings.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py", line 142, in aembeddings_wrapper
raise e
File "/usr/local/lib/python3.11/site-packages/opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py", line 127, in aembeddings_wrapper
response = await wrapped(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openai/resources/embeddings.py", line 215, in create
return await self._post(
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1816, in post
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1510, in request
return await self._request(
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1611, in _request
raise self._make_status_error_from_response(err.response) from None
openai.AuthenticationError: Error code: 401 - {'statusCode': 401, 'message': 'Unauthorized. Access token is missing, invalid, audience is incorrect (https://cognitiveservices.azure.com), or have expired.'}
2024-12-10 13:34:47,360 - 103.201.144.179:0 - "POST /upload HTTP/1.1" 500

@mdvohra mdvohra changed the title AZURE_AUTH_TENANT_ID openai.AuthenticationError: Error code: 401 - {'statusCode': 401, 'message': 'Unauthorized. Access token is missing, invalid, audience is incorrect (https://cognitiveservices.azure.com), or have expired.'} Dec 10, 2024
@pamelafox
Copy link
Collaborator

Please provide more details on your environment.

  • Are you getting this in production or local?
  • Are you using Azure OpenAI or OpenAI.com?
  • Can you share the logs from when your app starts up? That should show how your Azure OpenAI has been configured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants