Forum Discussion

ericOnline's avatar
ericOnline
Post Patron
5 years ago
Solved

How to create PBI API Authorization header from AppID and Secret?

I'm trying to use the PBI API to export reports to .png. I followed the docs to get an app registered in Azure and received an App ID and Secret. 

How do I create the Authorization header for API request using AppID and Secret?

The only examples I've been able to find all use C# or Java to create a "token". I don't have these tools at my disposal. Need an alternative, preferrably also using REST API of some sort. 

 

Thank you

  • ericOnline's avatar
    ericOnline
    5 years ago

    I figured it out. My client_secret had both a "+" and a "=" in it. I had to use the Flow action of encodeUriComponent. 
    Sweet!

4 Replies

  • Thank you for the resources. I've read through them.

     

    My challenge is trying to access the PBI REST API from outside PowerBI (from Power Automate in this case).  In the video example you shared, the person is using the Client_ID from their Azure registered app along with their own Username and Password to generate an access token. 

     

    This will not work in my case. 

     

    I need to generate a token with Client_ID and Client_Secret. How is this done?

    The error I'm receiving is Invalid Client Secret (though I've checked and double checked that the secret is correct):

     

     

    {
      "error": "invalid_client",
      "error_description": "AADSTS7000215: Invalid client secret is provided.\r\nTrace ID: 947ff77d-fc36-480d-a58c-011c126e7400\r\nCorrelation ID: 2af5df99-2ff6-41cb-a094-ca7d5750ef99\r\nTimestamp: 2021-02-24 17:30:39Z",
      "error_codes": [
        7000215
      ],
      "timestamp": "2021-02-24 17:30:39Z",
      "trace_id": "947ff77d-fc36-480d-a58c-011c126e7400",
      "correlation_id": "2af5df99-2ff6-41cb-a094-ca7d5750ef99",
      "error_uri": "https://login.microsoftonline.com/error?code=7000215"
    }

     

    • ericOnline's avatar
      ericOnline
      Post Patron

      I figured it out. My client_secret had both a "+" and a "=" in it. I had to use the Flow action of encodeUriComponent. 
      Sweet!

  • Following up here... the request I created above successfully returns a token, however the token is rejected when make a call to PowerBI REST API. 


    Why could that be?