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.
84 questions
Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,203 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,654 questions
{count} votes

1 answer

Sort by: Most helpful
  1. navba-MSFT 26,035 Reputation points Microsoft Employee
    2024-07-04T08:30:37.3066667+00:00

    @Pedro Briceño Welcome to Microsoft Q&A Forum, Thank you for posting your query here!.

    Firstly, before testing from the Powershell, You can try to open the article VideoIndexer generate Access Token REST API and then click on the TryIt option and fill the required fields and then check if you can generate the access token.

    .

    If it does, please update your Powershell script to invoke the above REST API.

    .

    Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.