Trying to get access token for power bi client getting unauthorized


  •  using (HttpClient client = new HttpClient())
                    var tokenEndpoint = @"";
                    var accept = "application/json";
                    client.DefaultRequestHeaders.Add("Accept", accept);
                    string postBody = @"resource=
                                    & grant_type=password

                    using (var response = await client.PostAsync(tokenEndpoint, new StringContent(postBody, Encoding.UTF8, "application/x-www-form-urlencoded")))
                        if (response.IsSuccessStatusCode)
                            var jsonresult = JObject.Parse(await response.Content.ReadAsStringAsync());
                            var stoken = (string)jsonresult["access_token"];
    Thursday, January 10, 2019 3:20 PM

All replies

  • I believe you are getting this error as the username/password which you are passing does not have access to Power BI. Please make sure that you are passing the PowerBI Credentials (Account User Name and Password) to REST API end point.
    Saturday, January 12, 2019 12:17 AM