В сборках iOS TestFlight, когда я вызываю AcquireTokenInteractive(), системный браузер (ASWebAuthenticationSession) никогда не открывается.
Появляется мой пользовательский интерфейс загрузки, но страница входа в B2C никогда не отображается.
/>
В конце концов, MSAL выдает:
Код: Выделить всё
MsalClientException: authentication_canceled
- Браузер открывается
- Загружается страница входа в B2C
- Перенаправление возвращается
- Аутентификация успешна
Мой iOS Info.plist
Код: Выделить всё
CFBundleURLTypes
CFBundleTypeRole
Editor
CFBundleURLName
msal-
CFBundleURLSchemes
msal
LSApplicationQueriesSchemes
msauth
msauthv2
msauthv3
msauthv3.0
Код: Выделить всё
public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
{
AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(url);
return true;
}
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
if (!NSUserDefaults.StandardUserDefaults.BoolForKey("firstLaunchDone"))
{
var pcaWrapper = (IPcaWrapper)Current.Services.GetService(typeof(IPcaWrapper));
var pca = ((PcaWrapper)pcaWrapper).PublicClientApplication;
var accounts = pca.GetAccountsAsync().Result;
foreach (var acc in accounts)
pca.RemoveAsync(acc).Wait();
NSUserDefaults.StandardUserDefaults.SetBool(true, "firstLaunchDone");
}
return base.FinishedLaunching(app, options);
}
Код: Выделить всё
public PcaWrapper(IConfiguration configuration)
{
settings = configuration.GetRequiredSection("Settings").Get();
Scopes = BuildScopes(settings);
string redirectUri = string.IsNullOrWhiteSpace(PlatformConfig.Instance.RedirectUri)
? settings.RedirectUri //
: PlatformConfig.Instance.RedirectUri;
PlatformConfig.Instance.RedirectUri = redirectUri;
authority = BuildAuthority(settings); // https:///
PublicClientApplication = PublicClientApplicationBuilder
.Create(settings.ClientId) //
.WithB2CAuthority(authority)
.WithRedirectUri(redirectUri)
.WithIosKeychainSecurityGroup("com.microsoft.adalcache")
.Build();
}
Код: Выделить всё
private async Task AcquireTokenInteractiveInternalAsync(string[] scopes)
{
var builder = PublicClientApplication
.AcquireTokenInteractive(scopes)
.WithB2CAuthority(authority)
.WithUseEmbeddedWebView(true);
if (PlatformConfig.Instance.ParentWindow != null)
{
builder = builder.WithParentActivityOrWindow(PlatformConfig.Instance.ParentWindow);
}
return await MainThread.InvokeOnMainThreadAsync(() => builder.ExecuteAsync());
}
Код: Выделить всё
"Settings": {
"ClientId": "",
"TenantId": "",
"Instance": "https://.b2clogin.com",
"Domain": ".onmicrosoft.com",
"SignUpSignInPolicyId": "",
"RedirectUri": "msal://auth",
"Scopes": [
{ "Value": "openid" },
{ "Value": "offline_access" }
]
}
- Приложение запускается
- Я вызываю AcquireTokenInteractive()
- Появляется мой пользовательский интерфейс загрузки
- Системный браузер никогда не открывается
- Нет страницы входа
- Нет перенаправление
- В конечном итоге MSAL выдает аутентификацию_canceled
Что я уже проверил
- URI перенаправления зарегистрирован в Azure B2C
- Схема сопоставления добавлена в Info.plist
- Набор группы доступа к связке ключей ()
Код: Выделить всё
com.microsoft.adalcache - AppDelegate.OpenUrl реализован
- Нет SceneDelegate (по умолчанию MAUI)
- Проверено встроенный + системный браузер
- Разрешения TestFlight отображаются правильно
В чем мне нужна помощь? понимаете?
Почему ASWebAuthenticationSession не открывается только в сборках TestFlight и может ли это быть вызвано отсутствием возможностей plist, проблемами формата URI перенаправления, необходимыми правами или какими-либо ограничениями, специфичными для TestFlight, влияющими на интерактивный вход в MSAL.NET MAUI?
Будем очень благодарны за любую помощь.>
Подробнее здесь: https://stackoverflow.com/questions/798 ... d-on-testf
Мобильная версия