Forum Discussion

JeremsB's avatar
JeremsB
New Member
3 years ago

Unable to get PowerBI Access token from the API

(Newbie to PowerBI)
Hello,

I have a back-end app (NestJS) registered in Azure AD and I want to use it to retrieve a Power BI embed token in order to display some reports on my front-end app (React)

I've followed this tutorial and I use this route to try to get my token
https://api.powerbi.com/v1.0/myorg/groups/*workspaceId*/reports/*reportId* 
In the header I have a Bearer coming from this function

 

 

   const clientCredentialRequest = {
      scopes: ['https://analysis.windows.net/powerbi/api/.default'],
    };

    return this.msalClient.acquireTokenByClientCredential(
      clientCredentialRequest,
    );

 

 

(my msalClient is working well cause I use it for other tasks and I got no problems)

I got this error when trying to retrieve the embed token

 

 

{
    "error": {
        "code": "PowerBINotAuthorizedException",
        "pbi.error": {
            "code": "PowerBINotAuthorizedException",
            "parameters": {},
            "details": [],
            "exceptionCulprit": 1
        }
    }
}

 

 

There is a step in the tutoriel that I think maybe is not good, is the step 7

I have not this menu on Power BI

The (new) layout is like this


Also a last idea to solve my pb is about the pricing and the prerequesties to display power bi reports in a react app I have only AAD do I need anything else ?

Thanks in advance

(Sorry for my english, I'm french ðŸ‡«ðŸ‡·)