@Kasyfil Albar Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
I was able to run the below python sample and generate the Access Token by invoking the VideoIndexer generate Access Token REST API.
Before you run this sample, please update the variables accordingly:
import requests
# Define your Azure Video Indexer account details
subscription_id = "b83c1ed3-XXX-XXX-XXX-2b83a074c23f"
resource_group_name = "MY-Resources-Group"
account_name = "MyIndexerName"
# Define your Azure credentials
client_id = "ad8a06b6-XXX-XXX-XXX-28fd86b57777"
client_secret = "5dY8Q~pPmm7qjomXXXXXVqdXXXXXXXXXeakhS5aJo"
tenant_id = "72f988bfXXX-XXX-XXX-2d7cd011db47"
# Define the Azure endpoints
auth_url = f"https://login.microsoftonline.com/{tenant_id}/oauth2/token"
token_url = f"https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.VideoIndexer/accounts/{account_name}/generateAccessToken?api-version=2024-01-01"
# Get the AAD token
aad_token_response = requests.post(
auth_url,
data={
"grant_type": "client_credentials",
"client_id": client_id,
"client_secret": client_secret,
"resource": "https://management.azure.com/"
}
)
aad_token = aad_token_response.json()["access_token"]
# Get the Video Indexer token
vi_token_response = requests.post(
token_url,
headers={
"Authorization": f"Bearer {aad_token}"
},
json={
"permissionType": "Contributor",
"scope": "Account"
}
)
vi_token = vi_token_response.json()["accessToken"]
print(vi_token)
Here is the screenshot of the access token, I got from the above sample:
Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.
**
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.