0

Library name and version using Azure.Identity 1.9.0

Query/Question Currently I pick up a acces token in the following way:

AuthenticationResult authenticationResult = null;
var authenticationContext = new AuthenticationContext(authorityUrl + $"{TenantId.Trim()}");
var credential = new ClientCredential($"{SPId}", $"{SPSecret}");
authenticationResult = authenticationContext.AcquireTokenAsync(resourceUrl, credential).Result;
return authenticationResult;

with

Within the new company regulations I cant no longer connect via this way and need to connect via ManagedIdentites.

In order to do this I wanted to make use of DefaultAzureCredential() With the following code:

var tokenCredential = new DefaultAzureCredential();
var tokenContext = new TokenRequestContext( scopes: new string[] { resourceUrl });
var accessToken = await tokenCredential.GetTokenAsync(tokenContext);

I do get a token back but if I try to connect to the PBI reports, I get a 401 not authorised error and I dont understand why.

Do I need to add the authorityUrl and TenentId somewhere? If so, where or why not? I cant find an example where this connection to PBI is made so I am really stuck here..

Mark Wekking
  • 391
  • 1
  • 5
  • 14
  • See : https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-organization-app – jdweng Jun 21 '23 at 08:47
  • looked at this allready but this doesn't work with managed identities – Mark Wekking Jun 21 '23 at 08:50
  • See : https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-organization-app#client-secret and https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-organization-app#step-3---add-the-required-nuget-packages – jdweng Jun 21 '23 at 09:00
  • I don't undetstand how I would use this? Could you explain this to me? – Mark Wekking Jun 21 '23 at 09:10
  • You have an authentication issue. Make sure authentication is enabled properly. – jdweng Jun 21 '23 at 09:45

0 Answers0