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.

[Bug] WebAuthenticator - iOS - Exception thrown for certain URIs #1307

@markdou812

Description

@markdou812

Description

When calling WebAuthenticator.AuthenticateAsync( ) with certain URIs the following exception is being thrown using Xamarin.Essentials.1.5.3.2 on iOS:

{System.Exception: Could not initialize an instance of the type 'Foundation.NSUrl': the native 'initWithString:' method returned nil.
It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.
at Foundation.NSObject.InitializeHandle (System.IntPtr handle, System.String initSelector) [0x000a8] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/Foundation/NSObject2.cs:504
at Foundation.NSUrl..ctor (System.String urlString) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/NSUrl.g.cs:141
at Xamarin.Essentials.WebAuthenticator.PlatformAuthenticateAsync (System.Uri url, System.Uri callbackUrl) [0x00113] in d:\a\1\s\Xamarin.Essentials\WebAuthenticator\WebAuthenticator.ios.tvos.cs:62
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 ... }

This same bug seems to have been fixed for Essentials Launcher: c32839b#commitcomment-39817362

Steps to Reproduce

  1. Call WebAuthenticator.AuthenticateAsync(https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/drive profile&client_id=810758826158-h3urg1c7jqj14hh0sdrripjj.apps.googleusercontent.com&redirect_uri=com.bradycorp.expresslabels:/oauth2redirect/google&response_type=code&code_challenge=Mb6ehw4vsDFyt8uT_GBvNGzj6WBDsUq6wl4P9xE7C9Q&code_challenge_method=S256, com.bradycorp.expresslabels:/oauth2redirect/google)
    (Auth URL slightly obfuscated here)

Expected Behavior

Call succeeds and the device's browser is launched.

Actual Behavior

System.Exception is thrown.

Basic Information

  • Version with issue: Xamarin.Essentials.1.5.3.2
  • Last known good version:
  • IDE: Visual Studio for Mac 8.6.3
  • Platform Target Frameworks:
    • iOS: 13.18.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions