I'm following the below documentation to authenticate against Microsoft Translator service with Microsoft Entra ID (Azure AD)
i'm stuck on the step to generate a token
important: key-based authentication is disabled on my translator instance therefore i've followed the docs above to another link to get token:
https://learn.microsoft.com/en-us/azure/ai-services/authentication?tabs=powershell#sample-request
this seems to be abit outdated as it's using Powershell ADAL module to request a token, however i ran it anyways:
Install-Module -Name ADAL.PS
Import-Module -Name ADAL.PS
$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList "https://login.windows.net/<TENANT_ID>"
$secureSecretObject = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.SecureClientSecret" -ArgumentList $SecureStringPassword
$clientCredential = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential" -ArgumentList $app.ApplicationId, $secureSecretObject
$token=$authContext.AcquireTokenAsync("https://cognitiveservices.azure.com/", $clientCredential).Result
$token
i filled in details with my serviceprincipal which has the roles assigned, yet i get no errors and $token returns empty
can anyone points me in the right direction please?
I have one service principal with Cognitive Services User role under Translator resource like this:
To generate the access token, make use of below updated PowerShell script:
Response:
Now, you can use this access token to call Microsoft Translator API successfully like this:
Response:
Reference: Translator Languages Method - Azure AI services | Microsoft