Speech API rejects requests with 401 whether using key or token

Marcus Bointon 21 Reputation points

I'm trying to call the speech API. The docs say I can use either a Ocp-Apim-Subscription-Key header containing my subscription key directly, or I can request an access token with a call to https://<REGION_IDENTIFIER>.api.cognitive.microsoft.com/sts/v1.0/issueToken, to obtain a JWT that I can then include in subsequent requests in an Authorization: Bearer <token> header. However, neither works. I can successfully obtain an access token (which I assume means that my key is correct), but then calls to the API endpoint using either authentication mechanism are rejected with a 401 error and no other info (content length of the response is 0). I am using the same region identifier for both calls. Is there something else I have to do?

Azure Speech
Azure Speech
An Azure service that integrates speech processing into apps and services.
765 questions
{count} votes

Accepted answer
  1. romungi-MSFT 27,196 Reputation points Microsoft Employee

    @Marcus Bointon Could you please clarify the public API you are referring to? I am referring to API similar to this:


    To simplify our conversation and demonstrate its usage I am using the API in the following way to use the service.

    1. Use the keys of the speech resource created in Azure to get the bearer token. API used https://<REGION_IDENTIFIER>.api.cognitive.microsoft.com/sts/v1.0/issueToken
    2. Used the bearer token along with a wav file as input to get the detailed response of the text. API used https://<region>.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1 90257-image.png


    If I use the same API with the key rather than the token, I get the same result.


1 additional answer

Sort by: Most helpful
  1. Marcus Bointon 21 Reputation points

    I think the problem is with my subscription key. When I set things up I just wanted to be able to auth and call a vision API, but I had to create a resource group and a resource of my own before I could do that. This was very confusing, and not something I expected to have to do, but I got it running. The subscription key I'm trying to use for speech is the one I use for that. I tried using it for another service and it didn't work:

    curl -X GET 'https://westeurope.api.cognitive.microsoft.com/bing/v7.0/search?q=Welsch%20Pembroke%20Corgis' -H 'Ocp-Apim-Subscription-Key:<my key>'

    Unlike the speech API's bare 401, this gives me an understandable error:

    {"error":{"code":"401","message": "The Search Operation under Web Search API - v7 is not supported with the current subscription key and pricing tier ComputerVision.F0."}}

    I don't have any other keys. If this is the wrong key, why does the issueToken endpoint work? Do I have to register a new account to get a different key?