Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 有人能在我的网站上提供一些关于电源BI嵌入问题的帮助吗_C#_Asp.net_Powerbi_Powerbi Embedded - Fatal编程技术网

C# 有人能在我的网站上提供一些关于电源BI嵌入问题的帮助吗

C# 有人能在我的网站上提供一些关于电源BI嵌入问题的帮助吗,c#,asp.net,powerbi,powerbi-embedded,C#,Asp.net,Powerbi,Powerbi Embedded,我正在努力使用Power BI Embedded在我的网页上呈现报告 我正在进行概念验证,并拥有一个公司Office 365帐户和一个Power BI Pro试用版。我们还有一个azure帐户,本地Active Directory将复制到该帐户。我有权访问office 365中的Power BI帐户,并可以在那里进行更改,但我没有访问Azure AD帐户的权限,必须请求在此处为我进行更改 我已进入我的Power BI帐户并创建了一份报告,并已将其发布到共享工作区。我们还在Azure中注册了一个指

我正在努力使用Power BI Embedded在我的网页上呈现报告

我正在进行概念验证,并拥有一个公司Office 365帐户和一个Power BI Pro试用版。我们还有一个azure帐户,本地Active Directory将复制到该帐户。我有权访问office 365中的Power BI帐户,并可以在那里进行更改,但我没有访问Azure AD帐户的权限,必须请求在此处为我进行更改

我已进入我的Power BI帐户并创建了一份报告,并已将其发布到共享工作区。我们还在Azure中注册了一个指向网站URL的应用程序

当我在Azure中查看应用程序时,我可以看到应用程序客户端ID、目录租户ID和对象ID。 应用程序ID URI以api://开头,并以应用程序客户端ID值继续

看了第9频道的视频,一切看起来都很简单,看了男生的代码也很有意义。但是,当我运行复制的代码时,我在使用的Reourse参数值、应用程序客户端ID和我的Azure AD凭据调用AcquireTokenAsync时出现了一个错误

错误内容如下:

AADSTS7000218:请求正文必须包含以下参数:“客户端断言”或“客户端机密”。 跟踪ID:d0bdb825-de11-43a0-8171-f5ef2e25dd00 相关ID:6dc1555b-b42b-46ea-93e5-9b1fa4c7fedd 时间戳:2020-01-1413:04:24Z

在任何地方都没有提到client_断言,但即使我确实有一个client_秘密,我可以在Azure中的应用注册中看到,我不清楚这将设置在哪里,或者这是一个令人费解的问题,我只是没有正确注册或配置应用

我希望其他人知道我为什么会看到这一点,并能建议一种解决方法,并怀疑这更多地与Power BI或Azure应用程序中的配置有关

我的方法如下所示

protected async void GetToken()
    {
        try
        {
            //  Config.AuthorityUrl = "https://login.windows.net/common/oauth2/authorize/"
            //  Config.ResourceUrl = "https://analysis.windows.net/powerbi/api"
            //  Config.ApiUrl = "https://api.powerbi.com/"
            //  These will be changed to use a service account later...
            //  Globals.DomainUsername = my AD account username
            //  Globals.DomainPassword = my AD account password
            //  Config.ClientID = Application (Client) ID in Azure app
            //  Config.GroupID = the Group ID taken from Power BI and matches the Application (Client) ID
            //  ReportID = the report ID taken from the Querystring when viewing report in Power BI

            var credentials = new UserPasswordCredential(Globals.DomainUsername, Globals.DomainPassword);
            var authenticationContext = new AuthenticationContext(Config.AuthorityUrl);
            var authenticationResult = await authenticationContext.AcquireTokenAsync(Config.ResourceUrl, Config.ClientID, credentials);

            if (authenticationResult == null)
            {
                throw new Exception("Could not get authenticationResult");
            }

            var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");

            using (var client = new PowerBIClient(new Uri(Config.ApiUrl), tokenCredentials))
            {
                var report = await client.Reports.GetReportInGroupAsync(Config.GroupID, ReportID);

                if (report == null)
                {
                    throw new Exception("Could not get report");
                }

                var generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view");
                var token = await client.Reports.GenerateTokenInGroupAsync(Config.GroupID, report.Id, generateTokenRequestParameters);

                if (token == null)
                {
                    throw new Exception("Could not get token");
                }

                // global scope variables...
                reportURL = report.EmbedUrl;
                rID = report.Id;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

我看到的唯一一件事是权威URL是不同的

我会尝试将AuthorityUrl更改为 或者{您的租户,例如contoso.onmicrosoft.com}/


此外,我还要再次检查您是否已将正确的Power BI API权限添加到Azure中的应用程序注册中。在我们开始切换到服务主体之前,我没有生成任何客户端密码。

您需要将该应用注册为本机应用。 将AuthorityUri更改为

根据Azure应用程序注册UI中的新更改,您需要将名为“默认客户端类型”的附加设置启用为“是”

为了更好地理解,请查看以下内容:

您注册的应用程序的类型是什么-web还是本机?您是否尝试将应用程序清单中的allowPublicClient设置为true?我刚刚将清单中的allowPublicClient设置为true,但我不确定如何/在何处检查应用程序类型。Andrey,这是一个web类型的应用程序,位于“管理”下的“身份验证”菜单选项下。URL指向调用AquireTokenAsync方法的页面。尝试注册本机应用程序是,即使对于web应用程序,有时也必须使用本机。