Forum Discussion

jjr10's avatar
jjr10
Frequent Visitor
3 years ago

POST request and refresh time on bearer token API

Hi all,

 

I've been building a dashboard which utalizes a few APIs from various sources, howver I am having issues with the one I am trying to bring in now.

 

Unlike the others, this API requires a initial HTTP POST request to be made to get a bearer token which is then used in the request to bring in the API. I have been able to make the POST request in Postman to retrieve the bearer token, which I then am able to use in PowerBI.

 

The POST request (on postman looks like this):

 

POST https://api.electricityinfo.co.nz/login/oauth2/token?grant_type=client_credentials&client_id=#myClientId&client_secret=#myClientSecret

 

with the client ID and Secret being those I get from signing up for use of this API. This all works fine, however the issue is I want to be able to do this step in PowerBI. The other problem is that this bearer token resets every 7200 seconds. I am wondering if there is a way around this so that I do not have to change this everytime a new token is issued?

 

Currently this is the request I am making in PowerBI to get the API through the use of the bearer token:

 

Get Data -> Web -> Advanced

I really appreciate anyones help, thanks all!

1 Reply