Here’s the guidance I need…here’s my method I’m calling the Auth0 login….
public async Task<string> LoginAuth0Async()
{
try
{
var auth0Client = new Auth0Client(new Auth0ClientOptions
{
Domain = "mycompany.auth0.com",
ClientId = "myclientId",
Scope = "openid profile email"
});
var user = await auth0Client.LoginAsync(RootView);
//UNHANDLE EXCEPTION HERE - Login Screen launches then app crashes - Null object ref. No other info comes back. I’m SURE it is IN the auth0Client.LoginAsync method and yes, RootView is set and is not null.
return user.IdentityToken; //never gets to here
}
catch(Exception ex) //never gets caught here either
{
return null;
}
}
As you can see from my comments in the code, I’m hitting an error calling the auth0Client.LoginAsync method. Those comments refer to Droid errors.
On iOS the login screen doesn’t even display and I get “Get method not found for AutomaticallyAdjustScrollViewInsets” error. I have no scrolling on any page, must be what auth0 is trying to display.
I don’t think the auth0Client.LoginAsync() method is handling the RootView/Context well and breaking internally, hence the unhandled exception.
I have similar mechanics in my MainActivity or AppDelegate that launches the login screen on startup and I can login, get token etc. then call the new service.
BUT I need this to work in the dependency SERVICE, not from MainActivity or AppDelegate
And what I’ve realised now is that after the line in the Service fires, it has nothing to return to. var loginResult= await auth0Client.LoginAsync(RootView)
I have tried to decorate the MainActivity with this: [IntentFilter(new[] { Intent.ActionView }, Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable }, DataScheme = “com.mycompany.mycompany”, DataHost = “mycompany.auth0.com”, DataPathPrefix = “/android/com.mycompany.mycompany/callback”)]
But that brings the return from the .LoginAsync call back to the MainActivity and NOT to where it is called.
Question, how can I get the result to return to here in the Service? var loginResult = await auth0Client.LoginAsync(RootView)
Maybe you can try creating a GitHub issue in the latter repo and the maintainer will suggest you how to tackle that as I’m not sure if Daniel will be able to help as it seems that you’re trying to pass the result from the other repo’s code.