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
Abrandhaug
Regular Visitor

Generating AccesToken in order to use PowerBI reports API

Hi, 

 

I've read all the previouse posts regarding this topic, but it seems I'm still kinda stuck.

 

As of now I've registered my App within app registrations in AAD. I've also added a security group and added my app (service principal) as a user and a owner of the security group. 

 

 

I've added a client secret to the app registration and I'm able to query: 

 

Abrandhaug_0-1663662425948.png

 

However when I then re-use the accesstoken generated in the response. I get 401:

Abrandhaug_1-1663662486753.png

 

 

These are the premissions I've granted the application in Azure: 

Abrandhaug_2-1663662547692.png



Any help will be greatly appreciated! 

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi  @Abrandhaug ,

Whether your problem has been resolved? If yes, could you please mark the helpful post as Answered? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yiruan-msft
Community Support
Community Support

Hi @Abrandhaug ,

According to the error message, it seems that service principal didn't have the proper permission. Did you add that service principal as the member/admin of the corresponding workspace just as describe in this official documentation

yingyinr_0-1663750848299.png

In addition, please check the following threads which have the similar problem as yours. Hope that the solution can also help you solve the problem.

Power Bi REST API - 401 Authorization error when using Service Principals

Add the Service Principal as an admin in the workspace directly rather than add the security group.

Acquired token gives 401 Unauthorized when trying to create DataSet

App registration (service principal) needs to be a member of a Security group

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.