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

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

我完成了这 tutorial and got all the required information / IDs / Parameters. Also watched these vids 中的每一步。

然而,在 运行 和 sample python code (flask app) 的最后阶段,在我的浏览器中打开本地主机 url 我得到这个错误:

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

我不明白为什么

我似乎无法获得令牌,401 在 pbiembedservice.py 中是 return 作为 api 响应(最后一行):

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())

其他帖子不是很有帮助,有人可以帮我吗

我知道问题出在哪里了。我需要将ADD(服务主体)中注册的应用程序添加到安全组,然后将其添加到Power BI Admin Portal -> Tenant setting -> Developer tap -> add it to the security group.