Embed-API-Sample icon indicating copy to clipboard operation
Embed-API-Sample copied to clipboard

Invalid status code 'Forbidden'

Open lamnv5490 opened this issue 8 years ago • 5 comments

Hi sir, I have run your sample then i got stucked in 2 case:

  1. I changed clientId, username, password then I got The request body must contain the following parameter: 'client_secret or client_assertion.
  2. After some researched I found that I should use var clientCre = new ClientCredential(clientId, clientSecret); This case I already got token. But then got stuck again in using (var client = new PowerBIClient(new Uri(apiUrl), tokenCredentials)) { var groups = client.Groups.GetGroups(); }. It said Microsoft.Rest.HttpOperationException: 'Operation returned an invalid status code 'Forbidden''.

I wonder that this sample is for Native ?

lamnv5490 avatar Nov 09 '17 14:11 lamnv5490

@lamnv5490 I got the same error!

ankit-h avatar Nov 10 '17 06:11 ankit-h

Same error here, I get Forbidden. Why they don't use the same auth metod as for PBI Collections?

aminebizid avatar Nov 19 '17 09:11 aminebizid

@aminebizid You should try Native App and dont forget to grant permission on AAD. if you try .NET Core. You will need to use REST API to get token, they just dont support .NET Core 2.0

lamnv5490 avatar Nov 19 '17 13:11 lamnv5490

@lamnv5490 I added PowerBi Service as required Permission on the principal. Do I need another permessions to make it work?

_clientCredential = new ClientCredential(myClientId, myClientSecret);

authenticationResult = await _authContext.AcquireTokenAsync("https://analysis.windows.net/powerbi/api", _clientCredential);

_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(Bearer, _authenticationResult.AccessToken);

var resp = await _httpClient.GetAsync("https://api.powerbi.com/v1.0/myorg/groups");

I get 401

aminebizid avatar Nov 20 '17 15:11 aminebizid

Have you click "Grant Permission"? I missed it once.

lamnv5490 avatar Nov 21 '17 03:11 lamnv5490