pit
pit

Reputation: 13

Azure Api Management get bearer token for Reports - List By Request

I have already created an application that hits the link " GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest?$filter={$filter}&api-version=2022-08-01 "

provided by Microsoft in the try out link here

In this link, after we sign in with our Azure credentials and add our subscriptionid + resource names and filter, we can get information about our API calls etc.

The problem that I face is that there after we sign in, it gives us a bearer token that can be used also to my application to bring those data. But I cannot find a way to take this bearer token programmatically without having to do the sign in. Is there such a way?

I tried to ask chatgpt, I tried also from postman some post links with client credentials but the bearer token that I took back and used gave me a response of unauthenticated.

enter image description here

Upvotes: 0

Views: 404

Answers (1)

Ikhtesam Afrin
Ikhtesam Afrin

Reputation: 6497

Please add user_impersonation permission to the registered app in Azure Entra ID.

enter image description here

enter image description here

You can generate the Bearer token as shown below-

Add resource: https://management.azure.com/

enter image description here

Access the API GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest?$filter={$filter}&api-version=2022-08-01 using the above generated token.

enter image description here

Upvotes: 0

Related Questions