I am seeking a way to automatically obtain and refresh a Power BI API access token within Power Query. I intend to use this token for further reporting, as documented by Microsoft here: https://learn.microsoft.com/en-us/rest/api/power-bi/
I have successfully registered an Azure application using the "Embed for your Organization" option: https://learn.microsoft.com/en-us/power-bi/developer/embedded/register-app
At this point, I can generate access token using OAuth 2.0 Client Credentials flow (https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow) in both Postman and Power Query. However, this token is not associated with an end user's credentials anymore, so all further reporting using this token lacks the necessary end user context.
The best approach seems to be OAuth 2.0 ROPC (https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth-ropc) using client_id, client_secret and userername+password with grant_type=password, however this is returning Status 400 with "AADSTS50126: Error validating credentials due to invalid username or password."
Notably, a Bearer token generated via the Try Me > Sign In here works perfectly.
I would appreciate any advice on how to proceed.