Skip to content
This repository was archived by the owner on May 15, 2024. It is now read-only.
This repository was archived by the owner on May 15, 2024. It is now read-only.

Xamarin.Essentials Web Authenticator throws NSErrorException if iOS permission to sign in is declined  #1240

@JohnBot2013

Description

@JohnBot2013

Description

When using Web Authenticator (in my case incorporating IdentityModel.OidcClient and using PKCE) then on iOS when the iOS permission to use the authority for sign in appears and you decline, an NSErrorException is thrown "Domain=com.apple.AuthenticationServices.WebAuthenticationSession Code=1" in WebAuthenticator.ios.tvos.cs at line 115

Steps to Reproduce

  1. Create a simple Xamarin Forms project and integrate the OidcClient into Web Authenticator using this example https://www.davidbritch.com/2020/04/authentication-from-xamarinforms-app_8.html.
  2. Ensure you are using flow as OidcClientOptions.AuthenticationFlow.AuthorizationCode (PKCE) and that the authority you are using is using shared cookies.
  3. Attempt to logon but decline the iOS permission to sign in using the authority.

Expected Behavior

WebAuthenticator fails gracefully. For example it returns a null response or an error response.

Actual Behavior

NSErrorException is thrown with the following stacktrace:
at Xamarin.Essentials.WebAuthenticator.PlatformAuthenticateAsync (System.Uri url, System.Uri callbackUrl) [0x003fc] in d:\a\1\s\Xamarin.Essentials\WebAuthenticator\WebAuthenticator.ios.tvos.cs:115
at TestIdentity.Browser.InvokeAsync (IdentityModel.OidcClient.Browser.BrowserOptions options, System.Threading.CancellationToken cancellationToken) [0x00034] in D:\DocComs\TestApps\ExampleDocComsOauth\TestIdentity\TestIdentity\Browser.cs:15
at IdentityModel.OidcClient.AuthorizeClient.AuthorizeAsync (IdentityModel.OidcClient.AuthorizeRequest request, System.Threading.CancellationToken cancellationToken) [0x000e7] in C:\local\identity\model\IdentityModel.OidcClient\src\AuthorizeClient.cs:63
at IdentityModel.OidcClient.OidcClient.LoginAsync (IdentityModel.OidcClient.LoginRequest request, System.Threading.CancellationToken cancellationToken) [0x00111] in C:\local\identity\model\IdentityModel.OidcClient\src\OidcClient.cs:73
at TestIdentity.IdentityViewModel.Login () [0x0004d] in D:\DocComs\TestApps\ExampleDocComsOauth\TestIdentity\TestIdentity\IdentityViewModel.cs:46

Basic Information

Xamarin.Forms V4.5.0.617
Xamarin.Essentials V1.5.3.1
Visual Studio 2019 Prof V16.5.4
iOS 13.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneed-more-informationNeed more information to investigate a bug or proposal

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions