我正在通过Xamarin编写的iOS和Android应用程序连接到Power BI Embedded。
我在https://docs.microsoft.com/en-us/power-bi/developer/get-azuread-access-token处处理了“应用拥有数据”的示例,但是,函数UserPasswordCredential无法用于在C#的Xamarin版本中创建AuthenticationContext。
我的问题:从Xamarin连接到Power BI Embedded是受支持的方案。如果是这样,欢迎使用指向文档/示例的指针。
您可以找到样本here
public Task<AuthenticationResult> Authenticate(string authority, string resource, string clientId, string returnUri)
{
var uri = new Uri(returnUri);
var authContext = new AuthenticationContext(authority);
var platformParams = new PlatformParameters(CrossCurrentActivity.Current.Activity);
if (authContext.TokenCache?.ReadItems()?.Any() is true)
authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);
return authContext.AcquireTokenAsync(resource, clientId, uri, platformParams);
}