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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

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

I took every steps in this [tutorial](https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-sample-for-customers?tabs=net-cor...) and got all the required [information / IDs / Parameters](https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-sample-for-customers?tabs=net-cor...). Also watched these [vids](https://youtube.com/playlist?list=PLib8Q64STW-tCZVSvBAuEIzBsVlf0C81f).

However, at the final stage when running the [sample python code (flask app)](https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-sample-for-customers?tabs=python#...), and opening the localhost url in my browser I get this error:

```
Error Details:
401 Unauthorized: Error while retrieving Embed URL
Unauthorized:
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 `pbiembedservice.py` 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

Args:
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.

Returns:
EmbedConfig: Embed token and Embed URL
'''

report_url = f'https://api.powerbi.com/v1.0/myorg/groups/{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

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous,

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.

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.