<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: PowerBIClient Forbidden issue in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301626#M8868</link>
    <description>@Jim, I am taking the App Owns Data approach. I have setup app in Azure AD and set permissions. I have created an app workdpace with 1 Power BI Pro user. I already have groupId and a dashboardId. Stuck on that 'Forbidden' exception when trying to generate Embed Token. My Azure AD app is a web-app one. I have read somewhere I need to setup native one?</description>
    <pubDate>Mon, 13 Nov 2017 05:28:10 GMT</pubDate>
    <dc:creator>Junilo</dc:creator>
    <dc:date>2017-11-13T05:28:10Z</dc:date>
    <item>
      <title>PowerBIClient Forbidden issue</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/246074#M7664</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We're investigating the user of Power BI embedded for our SaaS app. In our scenario, we own the data and our end users would be utilizing the reports as non-power-bi users.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been struggling for a few days now to craft a working sample. Some samples I've found are no longer working or are for the old power bi azure implementation that's led to dead ends; however, I've gotten to the point where I'm very close to simply embedding a report in our Power BI setup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a simple console app I've come up with, many parts are from various documentation articles. The token is obtained fine, but when the request is submitted, I recieve&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;HttpOperationException: Operation returned an invalid status code 'Forbidden'&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;private static string clientId = "----";
private static string secretKey = "----";
private static string groupId = "----";

        static void Main(string[] args)
        {
            string resourceUri = "https://analysis.windows.net/powerbi/api";

            string authorityUri = "https://login.windows.net/common/oauth2/authorize";

            ClientCredential credential = new ClientCredential(clientId, secretKey);
            AuthenticationContext authContext = new AuthenticationContext(authorityUri);

            string token = authContext.AcquireTokenAsync(resourceUri, credential).Result.AccessToken;

            var tokenCredentials = new TokenCredentials(token, "Bearer");

            using (var client = new PowerBIClient(new Uri("https://api.powerbi.com/"), tokenCredentials))
            {
                var reports = client.Reports.GetReportsInGroupWithHttpMessagesAsync(groupId);

                var faulted = reports.IsFaulted;

                // Here's where the exception is thrown
                var report = reports.Result.Body.Value;
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas why?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what we've validated/tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The AD User we've created the app under is not the global admin as recommended.&lt;/LI&gt;&lt;LI&gt;The user is a power bi pro user (trial).&lt;/LI&gt;&lt;LI&gt;The required permissions (Windows Azure Active Directory/Power BI Service) have been granted (we've checked off all to ensure we're not missing anything).&lt;/LI&gt;&lt;LI&gt;We've validated/confirmed the client ID, secret key and group id many times.&lt;/LI&gt;&lt;LI&gt;The Power BI workspace is private, but we've tried making a public one to be sure it doesn't matter.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 19:15:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/246074#M7664</guid>
      <dc:creator>emotix</dc:creator>
      <dc:date>2017-09-05T19:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBIClient Forbidden issue</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/247639#M7705</link>
      <description>&lt;P&gt;Small update:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The token we obtain is correct. We've confirmed the token used at powerbi.com matches the token we obtain for use in the API example above while observing the requests.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fiddler isn't of much help with the sample app from the first post, the raw request output is below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;HTTP/1.1 403 Forbidden
Content-Length: 0
Server: Microsoft-HTTPAPI/2.0
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Frame-Options: deny
X-Content-Type-Options: nosniff
RequestId: 1bcbd00c-e552-46f6-9d8e-81acd7534710
Date: Thu, 07 Sep 2017 18:18:39 GMT&lt;/PRE&gt;&lt;P&gt;Any help is much appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 18:20:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/247639#M7705</guid>
      <dc:creator>emotix</dc:creator>
      <dc:date>2017-09-07T18:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBIClient Forbidden issue</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/276384#M8288</link>
      <description>&lt;P&gt;Did you ever find a resolution for this?&amp;nbsp; I am encountering the same issue.&amp;nbsp; Please let me know.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 19:40:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/276384#M8288</guid>
      <dc:creator>noyesrichey</dc:creator>
      <dc:date>2017-10-11T19:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBIClient Forbidden issue</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/276385#M8289</link>
      <description>&lt;P&gt;Did you ever find a resolution for this?&amp;nbsp; I am encountering the same issue.&amp;nbsp; Please let me know.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 19:43:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/276385#M8289</guid>
      <dc:creator>noyesrichey</dc:creator>
      <dc:date>2017-10-11T19:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBIClient Forbidden issue</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/276478#M8291</link>
      <description>&lt;P&gt;You are mixing the directions for user&amp;nbsp;versus&amp;nbsp;app authentication.&amp;nbsp; If you plan on the users not having accounts you don't need to pass in or use a clientID and SecretKey.&amp;nbsp; Here is a code example.&amp;nbsp; You will just need a username, password and clientID to login.&amp;nbsp; If you want to opena report and/or dashboard you also need a workspace guid.&amp;nbsp; Let me know if you have any questions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;     var credential = new UserPasswordCredential(Username, Password);

            // Authenticate using created credentials
            var authenticationContext = new AuthenticationContext(AuthorityUrl);
            var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ClientId, credential);

            if (authenticationResult == null)
            {
                return View(new EmbedConfig()
                {
                    ErrorMessage = "Authentication Failed."
                });
            }

            var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");

            // Create a Power BI Client object. It will be used to call Power BI APIs.
            using (var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials))
            {
                // Get a list of reports.
                var reports = await client.Reports.GetReportsInGroupAsync(GroupId);

                // Get the first report in the group.
                var report = reports.Value.FirstOrDefault();&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 00:16:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/276478#M8291</guid>
      <dc:creator>jamesyoung</dc:creator>
      <dc:date>2017-10-12T00:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBIClient Forbidden issue</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301603#M8866</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/44159"&gt;@jamesyoung&lt;/a&gt;&amp;nbsp;I tried your snippet below and getting this exception:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;AdalException: {"error":"invalid_client","error_description":"AADSTS70002: The request body must contain the following parameter: 'client_secret or client_assertion'.\r\nTrace ID: 030b56e4-a488-406d-becc-742e836c1800\r\nCorrelation ID: fb6c997d-5324-4255-ab36-53743bd29c95\r\nTimestamp: 2017-11-13 03:59:19Z","error_codes":[70002],"timestamp":"2017-11-13 03:59:19Z","trace_id":"030b56e4-a488-406d-becc-742e836c1800","correlation_id":"fb6c997d-5324-4255-ab36-53743bd29c95"}: Unknown error&lt;/PRE&gt;&lt;P&gt;Here's what I tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;static async void GetEmbedToken()
        {&lt;BR /&gt;&lt;BR /&gt;// took out actual values for these&lt;BR /&gt;&lt;BR /&gt;var aadUserEmail="";&lt;BR /&gt;var aadPassword = "";&lt;BR /&gt;var groupId = "";&lt;BR /&gt;var clientId = "";&lt;BR /&gt;
            var credential = new UserPasswordCredential(aadUserEmail, aadPassword);

            // Authenticate using created credentials
            var authenticationContext = new AuthenticationContext("https://login.windows.net/common/oauth2/authorize/");
            var authenticationResult = await authenticationContext.AcquireTokenAsync("https://analysis.windows.net/powerbi/api", clientId, credential);

            if (authenticationResult != null)
            {
                var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");

                // Create a Power BI Client object. It will be used to call Power BI APIs.
                using (var client = new PowerBIClient(new Uri("https://api.powerbi.com/"), tokenCredentials))
                {
                    // Get a list of reports.&lt;BR /&gt;
                    var reports = await client.Reports.GetReportsInGroupAsync(groupId);

                    // Get the first report in the group.
                    var report = reports.Value.FirstOrDefault();
                }
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 04:04:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301603#M8866</guid>
      <dc:creator>Junilo</dc:creator>
      <dc:date>2017-11-13T04:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBIClient Forbidden issue</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301618#M8867</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/46758"&gt;@Junilo&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you trying to use the App method or the User method to login?&amp;nbsp; The user method just reuqires you have an account in Power BI and only allows users with Power BI accounts to access the report/dashboard.&amp;nbsp; The APP login method allows you to share your reports/dashboards with users who do not have a Power BI account but requires setup in Azure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 05:10:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301618#M8867</guid>
      <dc:creator>jamesyoung</dc:creator>
      <dc:date>2017-11-13T05:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBIClient Forbidden issue</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301626#M8868</link>
      <description>@Jim, I am taking the App Owns Data approach. I have setup app in Azure AD and set permissions. I have created an app workdpace with 1 Power BI Pro user. I already have groupId and a dashboardId. Stuck on that 'Forbidden' exception when trying to generate Embed Token. My Azure AD app is a web-app one. I have read somewhere I need to setup native one?</description>
      <pubDate>Mon, 13 Nov 2017 05:28:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301626#M8868</guid>
      <dc:creator>Junilo</dc:creator>
      <dc:date>2017-11-13T05:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBIClient Forbidden issue</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301642#M8871</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/46758"&gt;@Junilo&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's probably a client ID issue.&amp;nbsp; What line of code is it failing?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 05:47:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301642#M8871</guid>
      <dc:creator>jamesyoung</dc:creator>
      <dc:date>2017-11-13T05:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBIClient Forbidden issue</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301722#M8875</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Even i am facing the same issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My setup is similar to&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/46758"&gt;@Junilo&lt;/a&gt;'s setup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have registered my Web App in Azure and noted the ClientID and Client Secret.&lt;/P&gt;&lt;P&gt;I am not passing any user name and password so we are not using User Login authentication.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have pro license trial in powerBI and I have access to many dashboards.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When we do App authentication, the app must have access to Dashboard or Workspace?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yasotha&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 06:58:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301722#M8875</guid>
      <dc:creator>Yaostha</dc:creator>
      <dc:date>2017-11-13T06:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBIClient Forbidden issue</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301745#M8877</link>
      <description>From my first post, it is failing at AcquireTokenAsync where it says:&lt;BR /&gt;&lt;BR /&gt;AADSTS70002: The request body must contain the following parameter: 'client_secret or client_assertion'</description>
      <pubDate>Mon, 13 Nov 2017 07:25:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301745#M8877</guid>
      <dc:creator>Junilo</dc:creator>
      <dc:date>2017-11-13T07:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBIClient Forbidden issue</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301973#M8890</link>
      <description>&lt;P&gt;Same for me if I try to run the App Owns Data sample&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 11:21:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301973#M8890</guid>
      <dc:creator>Yaostha</dc:creator>
      <dc:date>2017-11-13T11:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBIClient Forbidden issue</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301976#M8891</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/43746"&gt;@Yaostha&lt;/a&gt;&amp;nbsp;and everyone having same issue, I have fixed mine. The key is to register the Azure AD app as a "Native" app, not "Server-side..."&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See my post here: &lt;A href="http://community.powerbi.com/t5/Developer/Obtain-Access-Token-C-App-Owns-Data-Error/m-p/301881#M8884" target="_self"&gt;http://community.powerbi.com/t5/Developer/Obtain-Access-Token-C-App-Owns-Data-Error/m-p/301881#M8884&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 11:26:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/301976#M8891</guid>
      <dc:creator>Junilo</dc:creator>
      <dc:date>2017-11-13T11:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBIClient Forbidden issue</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/610730#M18390</link>
      <description>&lt;P&gt;Everything works fine when authenticating using user + pass but when I'm trying the auth using client secret I get the "unauthorized" message. Hints?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx,&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jan 2019 15:13:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBIClient-Forbidden-issue/m-p/610730#M18390</guid>
      <dc:creator>paulsincai</dc:creator>
      <dc:date>2019-01-28T15:13:25Z</dc:date>
    </item>
  </channel>
</rss>

