Closed basilkurianmb closed 1 year ago
As our Auth0Client
is dependent on the OidcClient.LoginAsync
method (https://github.com/auth0/auth0-oidc-client-net/blob/master/src/Auth0.OidcClient.Core/Auth0ClientBase.cs#L59), this sounds like an issue with the OidcClient that is being used.
There is a related issue https://github.com/IdentityModel/IdentityModel.OidcClient/issues/54. Even tho it is closed, it doesn't look like it is fixed. Might want to discuss the issue to their repository.
Encountered the same issue. I found that when it authenticates successfully, it correctly triggers OnNewIntent within the activity and therefore hits the line ActivityMediator.Instance.Send(intent.DataString);
but when its cancelled, i.e. the browser is closed, then it just hangs on loginasync, never triggering OnNewIntent.
However, on closing the browser, I found it does still trigger OnResume. So my workaround was to add a boolean to the activity called "IsAuthenticating" which is set to true just before LoginAsync is triggered, and then add this to OnResume:
protected override void OnResume()
{
base.OnResume();
if (IsAuthenticating)
{
ActivityMediator.Instance.Send("com.company.myapp://myauthdomain.eu.auth0.com/android/com.company.myapp/callback");
}
}
This seems to finish the await loginasync and allow the app to continue. I also set the IsAuthenticating to false in OnNewIntent if the login is successful, so that when it hits onresume during a successful login, the ActivityMediator send isn't triggered.
@JonnySKK Did you manage to fix this? This has become unworkable as user keep closing the browsers without logging in.. I tried your fix, but can't get it to work. the instance.Send, is triggered but nothing happens
TIA
@JonnySKK The provided solution doesn't work for me also.
Any updates on this issue?
Same problem here and I cannot get and the solution by @JonnySKK to work. Any news on this?
Hey everyone, Not sure if you're still looking for a solution, but I used the above example for Xamarin to get the same behavior as iOS. Instead of `protected override void OnResume() { base.OnResume();
if (IsAuthenticating)
{
ActivityMediator.Instance.Send("com.company.myapp://myauthdomain.eu.auth0.com/android/com.company.myapp/callback");
}
}`
I removed the Activity Mediator line and just merely did the logout logic directly in the OnResume method in the MainActivity.
The replacement line for the Activity Mediator looks like this:
await Shell.Current.GoToAsync($"//{nameof(InsertPageHerePage)}");
I have the same problem and the solution @JonnySKK doesn't work. I'm getting "Malformed callbackk URL". @lukies97 could you please share a more detailed example of how did you make it work?
I also got a "Malformed callback URL". I used this instead, and it works for me:
if (IsAuthenticating)
{
ActivityMediator.Instance.Cancel();
}
if (IsAuthenticating) { ActivityMediator.Instance.Send("com.company.myapp://myauthdomain.eu.auth0.com/android/com.company.myapp/callback"); }
This solution doesn't working for me
I also got a "Malformed callback URL". I used this instead, and it works for me:
if (IsAuthenticating) { ActivityMediator.Instance.Cancel(); }
This works for me👌
Closing as it looks like there is a workaround available. If not, I would kindly refer to https://github.com/IdentityModel/IdentityModel.OidcClient/issues/54
For Xamarin Forms Android, the
await _auth0Client.LoginAsync()
is not returning any cancelled event while the browser is cancelled manually by user. For iOS, at-least it is returning null. Is there is any solution for it? Thanks for considering this topic.