active-directory-xamarin-native-v2
active-directory-xamarin-native-v2 copied to clipboard
MSAL confirmation dialog in Xamarin iOS
We are using the Microsoft MSAL library to authenticate our users. When a user needs to login, they are shown this dialog each time. Is there a way to disable this prompt so the login experience is more seamless?
@JohnLivermore : I think that this is iOS demanding the user to be aware of going to a specific URL. I don't think it can be disabled.
@JohnLivermore This pops up anytime the app uses SFAuthenticationSession or ASWebAuthenticationSession, we cannot change what is displayed there, as that is the point of the pop up. From Apple's developer site: " users are prompted by a dialog to give explicit consent, allowing the application to access the website’s data in Safari. When the webpage is presented, it runs in a separate process, so the user and web service are guaranteed that the app has no way to gain access to the user’s credentials. "
Closing as by-design, we have no control over this dialog.
cc: @jmprieur
Thanks for the clarification.
@JohnLivermore thanks for asking about it. we've had several customers ask about this.
@JohnLivermore
@SameerK-MSFT added an API, so you can opt out of seeing this screen now.
Option to hide prompt in iOS, when user attempts to login, iOS 13+ shows a prompt to the user. MSAL now provides an option to hide the prompt. To hide the prompt, create an instance of SystemWebViewOptions and set the iOSHidePrivacyPrompt to true.
Add the instance to PublicClientApplicationBuilder. That should hide the prompt. It is OK to add this to the common code between the platforms as it ignores the platforms where it is not applicable.
e.g.
// Hide the privacy prompt
SystemWebViewOptions systemWebViewOptions = new SystemWebViewOptions()
{ iOSHidePrivacyPrompt = true,};
var authResult = await App.PCA.AcquireTokenInteractive(App.Scopes)
.WithParentActivityOrWindow(App.ParentWindow)
.WithSystemWebViewOptions(systemWebViewOptions)
.ExecuteAsync();
This is in version 4.31.0
Running below code on android breaks with exception, should the exclusivity be ignored automatically on android ?

yes, you are right, we should get this fixed. The options should simply be ignored where they do not apply.
Until then, you'll have to conditionally add those options, e.g.
if (Device.OS == TargetPlatform.iOS)
{
builder = builder.WithSystemWebViewOptions();
}
