javascript - azure issue token api returning Access denied due to missing subscription key - Stack Overflow

I am trying to call bing text to speech azure services but i keep getting this error on getting the acc

I am trying to call bing text to speech azure services but i keep getting this error on getting the access token , although the subscription key is provided

function requestAudio(text,lang)
{
    nameLanguage = "Microsoft Server Speech Text to Speech Voice (en-GB, Susan, Apollo)";
    language = lang;
    textToSpeak = text;
    $.ajax(
    {
        type: 'POST',
        url: tokenURL,
        data: 
        {  
            'Ocp-Apim-Subscription-Key': 'xxxxxxf8cc34d08b646de1bc54c950d'
        }
    }).done(function(data) 
    { 
        token = data.access_token;
        sendAudioRequest();
    });
}

The error exactly from fiddler is

{ "statusCode": 401, "message": "Access denied due to missing subscription key. Make sure to include subscription key when making requests to an API." }

and the url i am calling is

.0/issueToken

I am trying to call bing text to speech azure services but i keep getting this error on getting the access token , although the subscription key is provided

function requestAudio(text,lang)
{
    nameLanguage = "Microsoft Server Speech Text to Speech Voice (en-GB, Susan, Apollo)";
    language = lang;
    textToSpeak = text;
    $.ajax(
    {
        type: 'POST',
        url: tokenURL,
        data: 
        {  
            'Ocp-Apim-Subscription-Key': 'xxxxxxf8cc34d08b646de1bc54c950d'
        }
    }).done(function(data) 
    { 
        token = data.access_token;
        sendAudioRequest();
    });
}

The error exactly from fiddler is

{ "statusCode": 401, "message": "Access denied due to missing subscription key. Make sure to include subscription key when making requests to an API." }

and the url i am calling is

https://api.cognitive.microsoft./sts/v1.0/issueToken
Share Improve this question edited Oct 4, 2017 at 1:41 abatishchev 100k88 gold badges301 silver badges442 bronze badges asked Feb 26, 2017 at 11:29 Mazen Abu TaweelihMazen Abu Taweelih 6471 gold badge9 silver badges24 bronze badges 1
  • Related posts - API management URL is giving Missing subscription key Issue] & Azure Api management Is it possible to disable Subscription Key – RBT Commented Sep 30, 2021 at 14:23
Add a ment  | 

1 Answer 1

Reset to default 5

I'm pretty sure you have to set those in the header, not in the body.

beforeSend: function(request) {
  request.setRequestHeader("Ocp-Apim-Subscription-Key", 'xxxxxxf8cc34d08b646de1bc54c950d');
},

Reference: https://msdn.microsoft./en-us/library/mt712546.aspx

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744965755a4603669.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信