I am fetching POWER BI admin and workspace information using the Power BI Rest API from the power BI Desktop which I plan to publish as a report later. I have written a function in Power Bi query editor to generate an access token which I am calling in my REST API call. All this works fine. But, how can I secure my function to generate access token. Currently, the username and password are being hardcoded in the function.
What is the best practice and how to make this more secure.
I solved a similar problem a while ago and found the best solution to be using this Power BI REST API Connector:
Article describing the connector: https://www.thepoweruser.com/2021/02/21/power-bi-rest-api-connector/