<?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: Operation returned an invalid status code 'Forbidden' GenerateTokenInGroupAsync in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Forbidden/m-p/610495#M18382</link>
    <description>&lt;P&gt;Hi. I'm having the same problem and I can't figure it out. I'm wondering if it's for the same reason as you. How would I check how many free token requests I have left?&lt;/P&gt;</description>
    <pubDate>Mon, 28 Jan 2019 11:04:55 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-01-28T11:04:55Z</dc:date>
    <item>
      <title>Operation returned an invalid status code 'Forbidden' GenerateTokenInGroupAsync</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Forbidden/m-p/372894#M11120</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting an error while executing the&amp;nbsp;GenerateTokenInGroupAsync().&amp;nbsp; The error "Operation returned an invalid status code 'Forbidden'".&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had users using the system all day, and the late afternoon this just stopped working.&amp;nbsp; I am using the following method to get the access token.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public static async Task&amp;lt;AccessToken&amp;gt; SetAccessToken()
        {
            List&amp;lt;KeyValuePair&amp;lt;string, string&amp;gt;&amp;gt; vals = new List&amp;lt;KeyValuePair&amp;lt;string, string&amp;gt;&amp;gt;
            {
                new KeyValuePair&amp;lt;string, string&amp;gt;("grant_type", "password"),
                new KeyValuePair&amp;lt;string, string&amp;gt;("scope", "openid"),
                new KeyValuePair&amp;lt;string, string&amp;gt;("resource", "https://analysis.windows.net/powerbi/api"),
                new KeyValuePair&amp;lt;string, string&amp;gt;("client_id", "XXXXX"),
                new KeyValuePair&amp;lt;string, string&amp;gt;("client_secret", "XXXXX"),
                new KeyValuePair&amp;lt;string, string&amp;gt;("username", "XXX"),
                new KeyValuePair&amp;lt;string, string&amp;gt;("password", "XXX")
            };
            string TenantId = "XXX";
            string url = string.Format("https://login.windows.net/{0}/oauth2/token", TenantId);
            HttpClient hc = new HttpClient();
            HttpContent content = new FormUrlEncodedContent(vals);
            HttpResponseMessage hrm = hc.PostAsync(url, content).Result;
            string responseData = "";
            if (hrm.IsSuccessStatusCode)
            {
                Stream data = await hrm.Content.ReadAsStreamAsync();
                using (StreamReader reader = new StreamReader(data, Encoding.UTF8))
                {
                    responseData = reader.ReadToEnd();
                }
            }
            AccessToken token = JsonConvert.DeserializeObject&amp;lt;AccessToken&amp;gt;(responseData);

            return token;
        }&lt;/PRE&gt;&lt;P&gt;I can retrieve the report details using&amp;nbsp;client.Reports.GetReportInGroupAsync().&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;var report = await client.Reports.GetReportInGroupAsync(groupId, reportId, CancellationToken.None);
                    
var generateTokenRequestParamaters = new GenerateTokenRequest(TokenAccessLevel.View, datasetId, allowSaveAs: null);
var tokenResponse = await client.Reports.GenerateTokenInGroupAsync(groupId, report.Id, generateTokenRequestParamaters, CancellationToken.None);&lt;/PRE&gt;&lt;P&gt;The error occurs when executing the last line of code in the code above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Remeez&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 07:17:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Forbidden/m-p/372894#M11120</guid>
      <dc:creator>remeez</dc:creator>
      <dc:date>2018-03-09T07:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: Operation returned an invalid status code 'Forbidden' GenerateTokenInGroupAsync</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Forbidden/m-p/377586#M11233</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/57407"&gt;@remeez&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please first follow the steps mentioned by Eric_Zhang in the following thread:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Developer/Generate-PowerBI-Embed-Token-gives-me-Forbidden-500-Internal/td-p/242526" target="_blank"&gt;https://community.powerbi.com/t5/Developer/Generate-PowerBI-Embed-Token-gives-me-Forbidden-500-Internal/td-p/242526&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 08:09:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Forbidden/m-p/377586#M11233</guid>
      <dc:creator>v-micsh-msft</dc:creator>
      <dc:date>2018-03-16T08:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Operation returned an invalid status code 'Forbidden' GenerateTokenInGroupAsync</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Forbidden/m-p/393742#M11717</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/12718"&gt;@v-micsh-msft&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the late response, the reason I was getting the error was because my account ran out of free token requests.&amp;nbsp; I had to switch on dedicated capacity in order to continue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Remeez&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 05:14:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Forbidden/m-p/393742#M11717</guid>
      <dc:creator>remeez</dc:creator>
      <dc:date>2018-04-11T05:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: Operation returned an invalid status code 'Forbidden' GenerateTokenInGroupAsync</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Forbidden/m-p/610495#M18382</link>
      <description>&lt;P&gt;Hi. I'm having the same problem and I can't figure it out. I'm wondering if it's for the same reason as you. How would I check how many free token requests I have left?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jan 2019 11:04:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Forbidden/m-p/610495#M18382</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-01-28T11:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: Operation returned an invalid status code 'Forbidden' GenerateTokenInGroupAsync</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Forbidden/m-p/1588267#M27145</link>
      <description>&lt;P&gt;Hi, I might have the same problem. Did you find a way to identify it? I mean, Any way to check the amount of token requests left?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 21:06:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Forbidden/m-p/1588267#M27145</guid>
      <dc:creator>RobertoBI</dc:creator>
      <dc:date>2021-01-08T21:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: Operation returned an invalid status code 'Forbidden' GenerateTokenInGroupAsync</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Forbidden/m-p/2553666#M36465</link>
      <description>&lt;P&gt;I am also looking to find out the number of token requests left. Were you able to find it?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2022 19:19:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Operation-returned-an-invalid-status-code-Forbidden/m-p/2553666#M36465</guid>
      <dc:creator>xaveri10</dc:creator>
      <dc:date>2022-06-01T19:19:35Z</dc:date>
    </item>
  </channel>
</rss>

