简体   繁体   中英

How do I properly use the access_token param in Azure's Text Translate API?

I am trying to call the Text Translate API using the access_token URL param, NOT any HTTP headers, to overcome CORS issues.

I have a valid subscription.

Here's what I'm doing:

  1. Get the access token as described here: https://docs.microsofttranslator.com/oauth-token.html I can get the token just fine.

  2. I'm calling the Text Translate API endpoint as described here: https://docs.microsofttranslator.com/text-translate.html Notice the part that says "Pass the access token to the Translator service using the Authorization header or the access_token query parameter."

I'm using this endpoint URL structure: https://api.microsofttranslator.com/V2/Http.svc/Translate?to=ja&text=cat&access_token=[ACCESS_TOKEN_FROM_STEP_1]

What am I doing wrong? The access token works if I use the Authorization header, but I don't want to use that as it breaks CORS.

Immediately after posting this question I found the answer :|

The correct URL structure is this: https://api.microsofttranslator.com/V2/Http.svc/Translate?to=ja&text=cat&appid=Bearer [ACCESS_TOKEN_FROM_STEP_1]

Thanks, MS, for your confusing documentation :( Also, how is the content of the Authorization header an app ID??

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM