0
votes

I am trying to use the Microsoft Custom Translator API(https://custom-api.cognitive.microsofttranslator.com/swagger/) to get list of the projects and so on. However I am receiving the 401 response (Unauthorized).

I am using the header authorization token as specified in similar Translator v3. API (https://docs.microsoft.com/en-us/azure/cognitive-services/translator/reference/v3-0-reference#authentication), however response is still 401.

The problem is not in the subscription, as the token authorization works well for the Translation v3. API.

Example of the call:

curl -X GET --header "Authorization: Bearer XYZ" https://custom-api.cognitive.microsofttranslator.com/api/texttranslator/v1.0/projects

Do you have any hints for the resolving the issue? Thank you.

2

2 Answers

1
votes

I found this sample code on GitHub. https://github.com/MicrosoftTranslator/CustomTranslatorApiSamples

This sample code shows "resouceUri" is not "https://graph.microsoft.com". Please set "api://6981666b-e0e0-47d6-a039-35318677bf79/access_as_user" when you request authonize and token.

And execute ex. "https://custom-api.cognitive.microsofttranslator.com/api/texttranslator/v1.0/workspaces" and Set to header "Authorization Bearer (access token)".
If you try on swagger, you have to write "Bearer (access token)".

0
votes

The Custom Translator API and the Translator V3 API are separate APIs. The Custom Translator API works with AAD v2 authentication since the operations on the Custom Translator are driven by the user as opposed to a subscription.

Please see below how to obtain an id_token for AAD v2. https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-get-jwt-token

The mechanism of using this token with Custom Translator API remains the same as you have mentioned above

--header "Authorization: Bearer XYZ"