Unable to access paid video indexer programmatically

Faiz ul Haque 5 Reputation points
2025-03-05T16:24:18.36+00:00

I am trying to utilize the Azure AI Video Indexer programmatically (directly from backend, without any UI or webbrowser).

My use case is:

  1. From the backend upload a a video and get the json data from video indexer.

I already tried many ways to get the azure video indexer token so that I can upload a upload, however, non of the works. here is the list:

  1. https://api-portal.videoindexer.ai/api-details#api=Operations&operation=Get-Account-Access-Token-With-PermissionI tried to use this method for the paid account (however, it's written that it's only for trial). Provided my subscription details from here: https://api-portal.videoindexer.ai/profile and it didn't work, also provided the azure subscription id also didn't work.
  2. second method I tried via creating Managed Application that actually give me the endpoints like /oauth2/v2.0/token and /oauth2/token, I tried "v2-oauth-ropc" method from this list: https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth-ropc (I can get the accessToken however, when I try to use that accessToken ad Authroization Bearer to get the azure indexer token, it says.
{
    "error": {
        "code": "AuthenticationFailed",
        "message": "Authentication failed."
    }
}

I am trying to follow this api documentation: https://learn.microsoft.com/en-us/rest/api/videoindexer/generate/access-token?view=rest-videoindexer-2025-01-01&tabs=HTTP&tryIt=true&source=docs#code-try-0

In the security section, it says

azure_auth

Azure Active Directory OAuth2 Flow

Type: oauth2 Flow: implicit Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Expand table

NameDescriptionuser_impersonationimpersonate your user accounthowever, this "user_impersonation" never works for me. And remember, it's backend api calls, no browser, or user interaction is there.

Any help full azure team would be highly appreciated.

Best,

Faiz

FYI: Guys, I have tried many solution, please don't just throw the guidance URL here, probably I have tried them already.

Azure AI Video Indexer
Azure AI Video Indexer
An Azure video analytics service that uses AI to extract actionable insights from stored videos.
{count} vote

2 answers

Sort by: Most helpful
  1. Faiz ul Haque 5 Reputation points
    2025-03-12T15:20:11.5266667+00:00

    @santoshkc

    Not sure, but in my use case (already tried to mention in the first comment in detailed), it's very poor suggestion to use Management API token for backend processing, as Management API token expires and I didn't find a way or @santoshkc didn't mention any way to refresh it.

    And When he says: "To generate the access token using POST command and here is the sample command syntax"

    May be @santoshkc don't bother to read the document further as that POST API, needs Bearer token with user_impersonation scope. Here is link: https://learn.microsoft.com/en-us/rest/api/videoindexer/generate/access-token?view=rest-videoindexer-2024-01-01&tabs=HTTP#azure-auth

    Now, It's really waste of money to pay the support fees here just to access this kind of support.


  2. Henrik Reer 20 Reputation points
    2025-05-09T13:02:11.39+00:00

    Hello @Faiz ul Haque ,

    I was in contact with Azure support myself about a different topic some time ago, and during that time, I too encountered the same issue as you describe. I was unable to use the Primary and Secondary Keys for my paid account, as those keys were linked only to my Trial account.

    To summarize; if you have an ARM account rather than a Trial or Classic account, the procedure is somewhat different, and you can't use the info provided under https://api-portal.videoindexer.ai/profile. Here is the response I got from one support engineer at Microsoft Azure Media and Communication Services:

    "In the context of a Video Indexer ARM Account, to use the Video Indexer API, the workflow is different from how you would use a Trial account or a Classic account and does not involve using Subscription Keys.

    While for Trial or Classic accounts, the access token could be generated using the API Portal: https://api-portal.videoindexer.ai/api-details#api=Operations&operation=Get-Account-Access-Token and required using Subscription Keys, for a Video Indexer ARM account, the procedure is different.

    To obtain the Account Access Token for ARM accounts, there are 2 options:

    • Option 1: From inside the Azure Portal:
      • You need to go to your Azure AI Video Indexer Account
        • Go to the Management API blade
          • Choose the permissions and the scope
            • Generate the token
    • Option 2: Using the REST API:

    {

    permissionType: "Contributor",

    scope: "Account"

    }

    • Click Run - action which will generate the access token

    Once you've generated the Account Access Token using one of the methods shared above, you can then go to the Video Indexer API Portal and run your required API requests using the previously-generated Account Access Token.

    For example, to run the List Videos API:

    • Follow this link:  https://api-portal.videoindexer.ai/api-details#api=Operations&operation=List-Videos
    • Complete the location, accountId and accessToken fields
    • Leave the Subscription Key field of the Authorization Header empty
    • As for the Ocp-Apim-Subscription-Key field, even though it does not influence the request in any way for a VI ARM Account, it is a required field in the portal, so, you can add any random value to it. Since your VI Account is ARM-based and you've already completed the accessToken field, the value inside the Ocp-Apim-Subscription-Key field will be ignored. (for example, while testing this functionality, I have added the "-" character to the field).
    • Run the request."

    To conclude; Even if the above is referring mainly to the use of the API web UI, you might get some insights from it, to use it programmatically as well as you want.

    Hope you find this helpful. Thanks.

    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.