When the chatbot works with an API key , and starts failing after switching to OAuth /Extra ID authentication ,the issue is usually one of these
1. Wrong token audience :(scope/resources)
For microsoft azure openAI the token which must be used is https://cognitiveservices.azure.com/.default
2. Using ID token instead of access token
OAuth login often returns
A. ID TOKEN
B. REFRESH TOKEN
C. ACCESS TOKEN
AND azure requires an access token , not ID token .
3. When the token expires and requires logic is missing
API key never misses key quickly. OAuth access token usually expires in an hour
So we need an automatic token refresh .
4.Service principal /managed identity lacks azure role
With API keys,RBAC is bypassed .
With the OAuth key , Azure RBAC matters.