Привет, я запускаю очень похожий код в приложении выше в приложении Maui, когда запускаю метод для вызова этого кода, мне предложено в устройстве Android выбрать свою учетную запись в корпорации, тогда мне спрашивают, хочу ли я продолжать Используйте мое названное имя приложения на том же устройстве Android, которое оно запускается, когда дело доходит до < /p>
result = await authenticationClient.AcquireTokenInteractive(_scopes)
.WithTenantId(_tenantId)
.ExecuteAsync()
.ConfigureAwait(false);
< /code>
, а затем просто не вешает больше журнала, просто не продолжает никаких советов ??? < /p>
:public class AuthenticationService : IAuthenticationService
{
// I recommend storing this in appsettings.json and grabbing it from IConfiguration instead
private readonly IPublicClientApplication authenticationClient;
private readonly string[] _scopes = new[] { "User.Read" };
private readonly string _tenantId = "[TENANT ID HERE]";
private readonly string _clientId = "[APP ID HERE]";
public AuthenticationService()
{
authenticationClient = PublicClientApplicationBuilder.Create(_clientId)
.WithAuthority(AzureCloudInstance.AzurePublic, _tenantId) // Only allow accounts in the tenant to authenticate
.WithRedirectUri($"msal{_clientId}://auth")
.Build();
}
public async Task AcquireTokenSilentAsync()
{
var accounts = await authenticationClient.GetAccountsAsync();
AuthenticationResult? result;
try
{
result = await authenticationClient.AcquireTokenSilent(_scopes, accounts.FirstOrDefault())
.ExecuteAsync();
}
catch (MsalUiRequiredException)
{
// Acquiring silently failed; need to acquire the token interactively
result = await AcquireTokenInteractiveAsync();
}
return result;
}
public async Task AcquireTokenInteractiveAsync()
{
if (authenticationClient == null)
return null;
AuthenticationResult result;
try
{
result = await authenticationClient.AcquireTokenInteractive(_scopes)
.WithTenantId(_tenantId)
.ExecuteAsync()
.ConfigureAwait(false);
return result;
}
catch (MsalClientException)
{
return null;
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... oid-device