active-directory-xamarin-native-v2 icon indicating copy to clipboard operation
active-directory-xamarin-native-v2 copied to clipboard

MSAL confirmation dialog in Xamarin iOS

Open JohnLivermore opened this issue 5 years ago • 7 comments

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?

enter image description here

JohnLivermore avatar Jan 21 '20 19:01 JohnLivermore

@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.

jmprieur avatar Jan 21 '20 19:01 jmprieur

@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

jennyf19 avatar Jan 23 '20 16:01 jennyf19

Thanks for the clarification.

JohnLivermore avatar Jan 23 '20 16:01 JohnLivermore

@JohnLivermore thanks for asking about it. we've had several customers ask about this.

jennyf19 avatar Jan 23 '20 16:01 jennyf19

@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

jennyf19 avatar May 12 '21 02:05 jennyf19

Running below code on android breaks with exception, should the exclusivity be ignored automatically on android ?

image image

walnut-co avatar May 27 '21 06:05 walnut-co

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();
 }

bgavrilMS avatar May 27 '21 09:05 bgavrilMS