locked
How do I get the bearer token for REST API to query reports on azure api management? RRS feed

  • Question

  • So I want to make this API call, which works if i grab the bearer token from my browser when I'm logged in, but I need to generate this.

    https://docs.microsoft.com/en-us/rest/api/apimanagement/2019-01-01/reports/listbyproduct

    So, I'm calling https://login.microsoftonline.com/{tenantId}/oauth2/token

    I created an app registration I added some API permissions, Microsoft Graph (user.read) What other permissions do I need to add here? I think this is where I've gone wrong.

    I get a forbidden error if I try to run it on postman with that bearer token.

    The Management API tab is somewhat useless it seems.

    Sunday, November 24, 2019 7:34 PM

Answers

  • Ok, I figured it out, so I did create the  'service principal' or app registration, I thought I added it to the IAM of the Azure API Management or I tried to add before and I didn't see it. So I tried again and I was able to add it 

    • Marked as answer by dan276 Monday, November 25, 2019 12:08 AM
    Monday, November 25, 2019 12:08 AM

All replies

  • I'm getting this now:

    The client 'xxxxxxxxxxxxxxxxxxxxxxxxx' with object id 'xxxxxxxxxxxxxxxxxxxx' does not have authorization to perform action 'Microsoft.ApiManagement/service/reports/read' over scope '/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/xxxxxxxxxxxxxxxxx/providers/Microsoft.ApiManagement/service/xxxxxxxxxxxx/reports/byProduct' or the scope is invalid. If access was recently granted, please refresh your credentials."

    I get this now that I added another permission to the app registration

    I'm not sure how to grant it permission

    Sunday, November 24, 2019 11:11 PM
  • Ok, I figured it out, so I did create the  'service principal' or app registration, I thought I added it to the IAM of the Azure API Management or I tried to add before and I didn't see it. So I tried again and I was able to add it 

    • Marked as answer by dan276 Monday, November 25, 2019 12:08 AM
    Monday, November 25, 2019 12:08 AM