Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
rajaniesh
Helper II
Helper II

Nodejs powerbi Get Token Request failing with AADSTS7000218

Hi,

I am using the sample provided at https://github.com/microsoft/PowerBI-Node and use the correct application ID along with the below config defined in the Jason config file.

 

{

"authorityUrl" : "https://login.microsoftonline.com/common/",

"resourceUrl" : "https://analysis.windows.net/powerbi/api",

"apiUrl" : "https://api.powerbi.com/",

"appId" : "",

"workspaceId" : "",

"reportId" : "",

"username" : "",

"password" : ""

}

 

But when this methid from the sample code given below

 

But when this method is called 


    // use user credentials and appId to get an aad token
    let promise = () => { return new Promise(
        (resolve, reject) => {
            context.acquireTokenWithUsernamePassword(config.resourceUrl, config.username, config.password, config.appId , function(err, tokenResponse) {
                if (err) reject(err);
                resolve(tokenResponse);
            })
        });
    };

 

then It throw this error.

Get Token request returned http error: 401 and server response: {"error":"invalid_client","error_description":"AADSTS7000218: The request body must contain the following parameter: 'client_assertion' or 'client_secret'.\r\nTrace ID: 6560c4b9-fe40-4120-ab2a-921956300000\r\nCorrelation ID: fd7fb0dd-e345-4206-b426-d121000f7393\r\nTimestamp: 2019-08-02 19:14:41Z","error_codes":[7000218],"timestamp":"2019-08-02 19:14:41Z","trace_id":"6560c4b9-fe40-4120-ab2a-921956300000","correlation_id":"fd7fb0dd-e345-4206-b426-d121000f7393"}

 

I do not understand why it is asking for client Secret because there is no option provided in this to specific client secret.

Not sure where I need to specify that . Not sure How can we make this sample work. I have use Azure Portal to register the App and assigning permission to PowerBI but that also did not worked and throwing the same error.

 

Any help would be really appreciated.

 

Regards

Rajaniesh

3 REPLIES 3
u02cm62
Helper V
Helper V

you get the secret when you register it as an Azure Web app (API/Web app Type).  If you registered as "Native" type, then there is no client secret.  https://dev.powerbi.com/apps

 

This basically registers it properly inside Azure portal for you, must easier than missing something in Azure Portal in my opinion, although, good to know how to properly do it yourself anyway as background info.

Also, you need to provide these values.  You get workspace ID from getting it in app.powerbi.com when navigating to the workspace, it provides the GUID in the url there.  You get the report ID by navigating to app.powerbi.com and clicking the report from the workspace, then in the url, the report guid will show up.  The username and password is the one who is registering it, and we always use a service account aka master user in the documentation or service principal (newer way recently if working with V2 of the workspaces).  Anything new for workspaces is V2.

"appId" : "",

"workspaceId" : "",

"reportId" : "",

"username" : "",

"password" : ""

Even after providing these values in the config file and registering the app it is not working.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors