Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSAL confirmation dialog in Xamarin iOS #114

Open
JohnLivermore opened this issue Jan 21, 2020 · 7 comments · Fixed by #167
Open

MSAL confirmation dialog in Xamarin iOS #114

JohnLivermore opened this issue Jan 21, 2020 · 7 comments · Fixed by #167

Comments

@JohnLivermore
Copy link

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

@jmprieur
Copy link
Contributor

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

@jennyf19
Copy link
Contributor

@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

@JohnLivermore
Copy link
Author

Thanks for the clarification.

@jennyf19
Copy link
Contributor

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

@jennyf19
Copy link
Contributor

@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 jennyf19 added the fixed label May 12, 2021
@SameerK-MSFT SameerK-MSFT linked a pull request May 13, 2021 that will close this issue
@walnut-co
Copy link

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

image
image

@bgavrilMS
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants