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

Exception thrown in WebAuthenticator in newer versions of Visual Studio/Xamarin.Essentials (worked for >2 years) #2088

Open
vsfeedback opened this issue May 30, 2023 · 1 comment

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:I'm unable to use this version] [regression] [worked-in:17.3.7]
Updates to Xamarin Essentials, or Xamarin.Android, or Visual Studio have broken our ability to log in within our Xamarin Forms application. Our application has been working fine for years. It's been deployed to the iOS/Android app stores since July 2021. The code hasn't changed. The only thing that's changed is operating system updates, and Visual Studio updates, which include updates to the Xamarin framework(s). Our deployed versions were tested and built in AppCenter with Xamarin.Android 13.1, and they are working fine. In recent versions of Visual Studio (both Windows and Mac) the Exception is thrown.

The only workaround I have been able to find so that I can log into the app in our development environments is to revert Visual Studio in Windows to a previous version. The bug does not appear when I revert to Visual Studio Version 17.3.7 with Xamarin.Android 13.0.0.

I have not figured out any workaround for Visual Studio for Mac, which is a barrier as some of our primary Xamarin developers work on Macs.

  • Is it possible to get a downlevel version of Visual Studio for Mac so that we are not blocking some near-term upcoming development while the issue is addressed?*

In recently released versions of Visual Studio/Xamarin, at login an exception is thrown with the message: "you must subclass the 'WebAuthenticatorCallbackActivity' and create and IntentFilter for it which matches your 'callbackUrl'.

The previously working code for the attributes from the class that subclasses Xamarin.Essentials.WebAuthenticatorCallbackActivity is below:

[Activity(NoHistory = true, LaunchMode = LaunchMode.SingleTop)]
[IntentFilter(new[] { Android.Content.Intent.ActionView },
Categories = new[] { Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable },
DataScheme = "projectname")]
public class WebAuthenticationCallbackActivity : Xamarin.Essentials.WebAuthenticatorCallbackActivity
{
}

The previously working code from the WebAuthenticator call is below:

WebAuthenticatorResult authResult =
await WebAuthenticator.AuthenticateAsync(new WebAuthenticatorOptions // this line throws exception
{
Url = new Uri(options. StartUrl),
CallbackUrl = new Uri("projectname://callback"),
PrefersEphemeralWebBrowserSession = true
});

This code had always worked for us (for over two years). The exceptions and versions information for updated Visual Studio in both Windows and Mac are below, along with the version info for the down-level version Visual Studio for Windows that does work.

The exception from Visual Studio on Windows is as follows:

{System.InvalidOperationException: You must subclass the WebAuthenticatorCallbackActivity and create an IntentFilter for it which matches your callbackUrl.
at Xamarin.Essentials.WebAuthenticator.PlatformAuthenticateAsync (Xamarin.Essentials.WebAuthenticatorOptions webAuthenticatorOptions) [0x0008e] in D:\a_work\1\s\Xamarin.Essentials\WebAuthenticator\WebAuthenticator.android.cs:65
at Project.Services.WebAuthenticatorBrowser.InvokeAsync (IdentityModel.OidcClient.Browser.BrowserOptions options, System.Threading.CancellationToken cancellationToken) [0x0008c] in C:\git\Project\Services\WebAuthenticatorBrowser.cs:27 }

Relevant Version numbers:
Microsoft Visual Studio Professional 2022
Version 17.6.0
VisualStudio.17.Release/17.6.0+33712.159
Microsoft .NET Framework
Version 4.8.09037

Installed Version: Professional

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio 17.6.41 (790a401)
Support for debugging Mono processes with Visual Studio.

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

Xamarin 17.6.0.251 (d17-6@318364c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK 13.2.0.6 (d17-5/a200af1)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: 6dd9def
Java.Interop: xamarin/java.interop/d17-5@149d70fe
SQLite: xamarin/sqlite@68c69d8
Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@9f02d77

The Exception from a Visual Studio for Mac is as follows:

System.InvalidOperationException: You must subclass the WebAuthenticatorCallbackActivity and create an IntentFilter for it which matches your callbackUrl.
at Xamarin.Essentials.WebAuthenticator.PlatformAuthenticateAsync (Xamarin.Essentials.WebAuthenticatorOptions webAuthenticatorOptions) [0x0008e] in D:\a_work\1\s\Xamarin.Essentials\WebAuthenticator\WebAuthenticator.android.cs:65
at Project.Services.WebAuthenticatorBrowser.InvokeAsync (IdentityModel.OidcClient.Browser.BrowserOptions options, System.Threading.CancellationToken cancellationToken) [0x0008c] in /Users/username/Projects/Solution/Project/Services/WebAuthenticatorBrowser.cs:27

Visual Studio Community 2022 for Mac
Version 17.5.5 (build 12)

Runtime
.NET 7.0.1 (64-bit)
Architecture: Arm64
Microsoft.macOS.Sdk 12.3.2372; git-rev-head:754abbf6a3563f6267e5717ae832b4ac25b1f2fb; git-branch:release/7.0.1xx-xcode13.3

Xamarin.Profiler
Version: 1.8.0.49
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode: 14.2 21534
Build: 14C18

Xamarin.Mac
Not Installed

Xamarin.iOS
Version: 16.4.0.6 Visual Studio Community
Hash: 97731c92c
Branch: xcode14.3
Build date: 2023-04-11 22:38:36-0400

Xamarin Designer
Version: 17.5.3.47
Hash: e8b5d371c3
Branch: remotes/origin/d17-5
Build date: 2023-05-12 16:19:05 UTC

Xamarin.Android
Version: 13.2.0.0 (Visual Studio Community)
Commit: xamarin-android/d17-5/797e2e1
Android SDK: /Users/macadmin/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
13.0 (API level 33)

SDK Command-line Tools Version: 7.0
SDK Platform Tools Version: 33.0.3
SDK Build Tools Version: 32.0.0

Build Information:
Mono: 6dd9def
Java.Interop: xamarin/java.interop/main@149d70fe
SQLite: xamarin/sqlite@fdc1e34
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@9f02d77

Microsoft Build of OpenJDK
Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk
11.0.16.1
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Eclipse Temurin JDK
Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk
1.8.0.302
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 17.5.0.33
Hash: f0c0c52
Branch: remotes/origin/d17-5~2
Build date: 2023-05-12 16:19:10 UTC

Android Device Manager
Version: 0.0.0.1245
Hash: 7f8a990
Branch: 7f8a990
Build date: 2023-05-12 16:19:10 UTC

Build Information
Release ID: 1705050012
Git revision: 4bfbea94ce18d0c248460d1250770e8e90d3a2ff
Build date: 2023-05-12 16:17:23+00
Build branch: release-17.5
Build lane: release-17.5

Operating System
Mac OS X 13.1.0
Darwin 22.2.0 Darwin Kernel Version 22.2.0
Fri Nov 11 02:04:44 PST 2022
root:xnu-8792.61.2~4/RELEASE_ARM64_T8103 arm64


The following is version information for the Visual Studio that I reverted to in which the code does not throw the exception:
Microsoft Visual Studio Professional 2022
Version 17.3.7
VisualStudio.17.Release/17.3.7+33027.108
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Professional

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio 17.3.20 (3f4cb00)
Support for debugging Mono processes with Visual Studio.

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

Xamarin 17.3.0.308 (d17-3@56b9f7e)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK 13.0.0.0 (d17-3/030cd63)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: dffa5ab
Java.Interop: xamarin/java.interop/d17-3@7716ae53
SQLite: xamarin/sqlite@df4deab
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@14076a6


Original Comments

Feedback Bot on 5/25/2023, 06:33 PM:

(private comment, text removed)


Original Solutions

(no solutions)

@ebcdavid
Copy link

This has been reported for a month. Will someone be addressing it? Will someone be able to provide us a down-level version of Visual Studio for Mac that doesn't have the regression? Please advise.

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

No branches or pull requests

2 participants