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

InvalidOperationException when using same callback scheme for WebAuthenticatorCallbackActivity and MainActivity #21293

Closed
shobanasuresh opened this issue Mar 19, 2024 · 4 comments
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/android 🤖 s/needs-repro Attach a solution or code which reproduces the issue t/bug Something isn't working

Comments

@shobanasuresh
Copy link

shobanasuresh commented Mar 19, 2024

Description

We are encountering a System.InvalidOperationException with the message "You must subclass the WebAuthenticatorCallbackActivity and create an IntentFilter for it which matches your callbackUrl" when we try to use the same callback scheme for WebAuthenticatorCallbackActivity and MainActivity in our project.

This issue is preventing us from using the same callback scheme across these 2 activities, which is a requirement in our project.
We have a single callback scheme assigned to our app. And, we have a requirement to use this scheme for both WebAuthenticatorCallbackActivity(initial login workflow) and also with MainActivity(to launch our app from other apps)

Steps to Reproduce

  1. Create a new maui app
  2. Follow instructions for WebAuthenticator for Android https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/communication/authentication?view=net-maui-8.0&tabs=android
  3. Use the same callback scheme for WebAuthenticatorCallbackActivity and MainActivity.
    e.g.,
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, NoHistory = true, LaunchMode = LaunchMode.SingleTask, Exported = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
[IntentFilter(new[] { Android.Content.Intent.ActionView },
                Categories = new[] {
                    Android.Content.Intent.CategoryDefault,
                    Android.Content.Intent.CategoryBrowsable },
                DataScheme = "my-app")]

public class MainActivity : MauiAppCompatActivity
[Activity(NoHistory = true, LaunchMode = LaunchMode.SingleTask, Exported = true)]
[IntentFilter(new[] { Android.Content.Intent.ActionView },
                Categories = new[] {
                    Android.Content.Intent.CategoryDefault,
                    Android.Content.Intent.CategoryBrowsable },
                DataScheme = CALLBACK_SCHEME)]
public class MyWebAuthenticationCallbackActivity : global::Microsoft.Maui.Authentication.WebAuthenticatorCallbackActivity
{
    const string CALLBACK_SCHEME = "my-app";
}
  1. Run the application.
  2. Observe the System.InvalidOperationException.

Expected behavior:
The application should run without throwing an exception, allowing the same callback scheme to be used across different activities.

Actual behavior:
The application throws a System.InvalidOperationException when the same callback scheme is used for WebAuthenticatorCallbackActivity and MainActivity.

We would appreciate any guidance or fixes for this issue. Thank you.

Link to public reproduction project repository

No response

Version with bug

8.0.7 SR2

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

@shobanasuresh shobanasuresh added the t/bug Something isn't working label Mar 19, 2024
@Redth
Copy link
Member

Redth commented Mar 19, 2024

I'm not able to reproduce it with the steps you shared. The app runs fine for me with both intent filters using the same data scheme (though I'm not sure this is really the right way to achieve what you're after?).

Please add a repro to this issue.

@Redth Redth added the s/needs-repro Attach a solution or code which reproduces the issue label Mar 19, 2024
@Redth Redth added this to the Backlog milestone Mar 19, 2024
Copy link
Contributor

Hi @shobanasuresh. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@dotnet-policy-service dotnet-policy-service bot added the s/no-recent-activity Issue has had no recent activity label Mar 28, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@Eilon Eilon added the area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info label Mar 28, 2024
@dotnet-policy-service dotnet-policy-service bot added s/no-recent-activity Issue has had no recent activity and removed s/no-recent-activity Issue has had no recent activity labels Mar 28, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@dotnet-policy-service dotnet-policy-service bot removed this from the Backlog milestone Apr 8, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 9, 2024
@dotnet-policy-service dotnet-policy-service bot removed the s/no-recent-activity Issue has had no recent activity label May 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/android 🤖 s/needs-repro Attach a solution or code which reproduces the issue t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants