Hello, interesting that someone is facing the same problems.
It's almost the same environment but my Bearer Token is generated by "PublicClientApplicationBuilder" for a GraphClient in a legacy application.
A rest api call of the Translator is running from time to time but mostly does not.
Same behaviour if I try to run the api call with the same bearer token in postman.
But processing a chat completion call (as well in the application as in postman) with the same bearer token is running all the time.
I'm sure the bearer token is correct!
But I do not know what is going wrong most of the time?
Intermittent 401001 Error in Azure Translator API Despite Valid Access Token
Tamil Selvam
5
Reputation points
Hi Azure team,
I’m facing an intermittent issue while integrating the Azure AI Text Translator API with a backend application using a token generated via Azure AD client credentials flow.
🔍 Problem:
The access token is retrieved successfully using an Azure AD App Registration (client credentials flow). The token is valid for 60 minutes and the claims are correct (aud
, nbf
, exp
). However, the Translator API calls behave inconsistently:
- First request often fails with: { "error": {
} }"code": "401001", "message": "The request is not authorized because credentials are missing or invalid."
- The second or third attempt works, fourth, fifth, six failed and 7th works using the same token
- Then a retry works again — all with the same unexpired token
- Token Endpoint Used: https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token
- resource: https://cognitiveservices.azure.com, Scope: https://cognitiveservices.azure.com/.default
- Token is passed as: Authorization: Bearer <access_token> Translator API endpoint: https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=de
- Setup:
- In Azure, I've created the Entra ID application, and generated the secret for that and provide the respective cognitive service user role to the service principle.
- Authenticate with Microsoft Entra ID: https://learn.microsoft.com/en-us/azure/ai-services/authentication?tabs=powershell#authenticate-with-azure-active-directory
- What We've Tried:
- Retrying after 401 (sometimes it works)
- Introducing a 2–3 second delay after token issuance
- Refreshing the token on 401
- Using Postman: the same token behaves inconsistently
- No limits are hit, and the Cognitive Service resource is active
- My Questions:
- Why is the Translator API randomly rejecting a valid, unexpired token?
- Is this related to regional token propagation across Translator servers?
- Are there known caching or delay issues after issuing a new token?
- What’s the best-practice recommendation to ensure stable token usage for Translator API across retries?
Azure AI Translator
Azure AI Translator
An Azure service to easily conduct machine translation with a simple REST API call.
1 answer
Sort by: Most helpful
-
Kalle Gerarts 40 Reputation points
2025-08-07T12:30:50.4266667+00:00