Share via

Is it considered acceptable/safe to use an Azure AD access token in the browser for Cognitive Services when /issueToken is unavailable?

Brett Jewell 20 Reputation points
2025-11-18T21:55:02.5466667+00:00

I am currently using the /issueToken endpoint to obtain a short-lived token, which I then pass to the frontend browser client for use with the Speech SDK.

I am migrating to a Speech resource configured with a private endpoint, which means the /issueToken endpoint is no longer available.

My plan is to use the Microsoft Entra (Azure AD) authentication flow to acquire an Azure AD access token.

Is it considered acceptable and safe to pass this Azure AD token directly to a frontend browser client for use with the Speech SDK? If not, what are the recommended alternatives or best practices in this scenario?

Related documentation:

Azure Speech in Foundry Tools

Answer accepted by question author

Anonymous
2025-11-19T00:24:30.8933333+00:00

Hi Brett Jewell

Welcome to Microsoft Q&A,

Passing an Azure AD access token directly to a browser client for Cognitive Services (e.g., Speech SDK) is not recommended for security reasons. Here’s why and what you should do instead:
It’s Risky

  • Exposure of a powerful token: An Azure AD access token typically grants broad permissions tied to the user or app identity. If leaked (e.g., via browser dev tools, logs, or XSS), it could be misused to access other Azure resources.
  • Longer lifetime than /issueToken: Unlike the short-lived token from /issueToken (usually ~10 minutes), Azure AD tokens often last 1 hour or more, increasing the attack window.
  • No resource scoping: The token might allow access beyond Speech services unless you strictly scope it to the Speech resource.

Recommended Alternatives

  1. Use a Backend Token Broker
    • Implement a secure server-side component that:
    • Authenticates with Azure AD.
    • Exchanges the token for a short-lived Speech service token (or signs requests if using private endpoints).
    • Returns only the minimal token to the browser.
    • This mimics /issueToken behavior and keeps sensitive credentials off the client.
  2. Enable Managed Identity or Service Principal
    • For private endpoints, authenticate your backend using a managed identity or service principal.
    • The backend then calls Speech service and streams audio results to the client (instead of exposing tokens).
  3. If Direct Token Use Is Unavoidable
    • Scope the token: Request an access token for the Speech resource only (https://cognitiveservices.azure.com/.default).
    • Use HTTPS and secure storage: Never store tokens in localStorage; keep them in memory.
    • Shorten lifetime: Use conditional access or token lifetime policies to minimize exposure.

Notes:

  • Never expose long-lived or broadly scoped tokens to the browser.
  • Always prefer a backend proxy pattern for private endpoints.
  • If you must use Azure AD tokens in the browser, apply strict scoping and lifetime controls.

I Hope this helps. Do let me know if you have any further queries.

Thank you!

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.