Issue obtaining access token for Azure Video Indexer using PowerShell

Pedro Briceño 0 Reputation points
2024-07-03T17:23:33.82+00:00

Hello,

I'm trying to obtain an access token for Azure Video Indexer using PowerShell. Here is what I've done so far:

Created a Video Indexer account:

  • Subscription ID: 06a3bdd8-f407-4903-9161-f7101c66d9e1
    • Account ID: ade73671-7aa2-4a99-9081-f554a1ca917a
      • Location: eastus
        • Subscription Key: b6af2f193c394a6abee013d8399d46b4
        Assigned appropriate roles:
        - I have assigned the `Owner` role to my user account.
        
        **PowerShell Script**:
        
        ```powershell
        powershellCopy code
        # Define your credentials and Azure Video Indexer settings
        

$subscriptionKey = "b6af2f193c394a6abee013d8399d46b4" # Primary subscription key $location = "trial" # The location of your Video Indexer account, use "trial" if it's a trial account $accountId = "ade73671-7aa2-4a99-9081-f554a1ca917a" # Your Video Indexer account ID

Function to get an access token

function Get-AccessToken { param ( [string]$subscriptionKey, [string]$location, [string]$accountId )

$uri = "https://api.videoindexer.ai/Auth/$location/Accounts/$accountId/AccessToken?allowEdit=true"
$headers = @{
    "Ocp-Apim-Subscription-Key" = $subscriptionKey
}

$response = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers
return $response
```}

# Get the access token
$accessToken = Get-AccessToken -subscriptionKey $subscriptionKey -location $location -accountId $accountId
Write-Output "Access Token: $accessToken"
               ```
               
       **Error Message**:

       
       ```json
       plaintextCopy code
       {

"ErrorType": "USER_NOT_ALLOWED", "Message": "User has no permission on account"

               ```
               
Azure AI Video Indexer
Azure AI Video Indexer
An Azure video analytics service that uses AI to extract actionable insights from stored videos.
68 questions
Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,912 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,273 questions
{count} votes