Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

401 Unauthorized: Error while retrieving Embed URL (embed power bi for customers-Python)

I took every steps in this [tutorial]( and got all the required [information / IDs / Parameters]( Also watched these [vids](

However, at the final stage when running the [sample python code (flask app)](, and opening the localhost url in my browser I get this error:

Error Details:
401 Unauthorized: Error while retrieving Embed URL
RequestId: 0b143776-bc54-492e-80bc-5401ecf32fd3

Which I can't figure out why

it seems that I'm unable to get the token and 401 is return in `` as the api response (last line):
class PbiEmbedService:

def get_embed_params_for_single_report(self, workspace_id, report_id, additional_dataset_id=None):
'''Get embed params for a report and a workspace

workspace_id (str): Workspace Id
report_id (str): Report Id
additional_dataset_id (str, optional): Dataset Id different than the one bound to the report. Defaults to None.

EmbedConfig: Embed token and Embed URL

report_url = f'{workspace_id}/reports/{report_id}'
api_response = requests.get(report_url, headers=self.get_request_header())

Other posts were not very helpful, can someone help me with that

Community Support
Community Support

Hi @MasGh,

Have you checked the device configurations to confirm if firewall policy and port settings enabled correctly?

Add Power BI URLs to allow list - Power BI | Microsoft Docs

BTW, current power bi embedded features seem not able to be used offline, these token functions required to access to azure service.


Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Get Ready for Power BI Dev Camp

Power BI Dev Camp - June 24th

Mark your calendars and join us for our next Power BI Dev Camp!

Top Kudoed Authors