auth0-samples / auth0-xamarin-oidc-samples

Auth0 OIDC Client with Xamarin applications
MIT License
30 stars 38 forks source link

NullReferenceException in iOS on client.LoginAsync(); #13

Closed joshuatantonflynn closed 5 years ago

joshuatantonflynn commented 6 years ago

I define my client as follows:

Auth0Client client = new Auth0Client( new Auth0ClientOptions { Domain = ConstantsData.Auth0Domain, ClientId = ConstantsData.Auth0ClientId } );

var loginResults = await client.LoginAsync();

The System.NullReferenceException happens here. If I mouse over client, it clearly was defined and has data. Below is my Stack Trace as requested but I don't see how that well help you one bit.

[External Code] 

0x76 in CoachingApp.iOS.HomeViewController.InitLogin at C:\Users\joshua.tanton\Documents\Projects\CoachingMobileApp\Coaching.iOS\HomeViewController.cs:316,17 C# 0x372 in CoachingApp.iOS.HomeViewController.ViewDidLoad at C:\Users\joshua.tanton\Documents\Projects\CoachingMobileApp\Coaching.iOS\HomeViewController.cs:486,5 C# 0x8 in CoachingApp.iOS.Application.Main at C:\Users\joshua.tanton\Documents\Projects\CoachingMobileApp\Coaching.iOS\Main.cs:12,6 C#

The crash is clearly happening on external code (Auth0 code). This was working fine until two days ago. I downgraded to 1.0 and it still gave me this issue, I'm back on 2.1 now.

jerriep commented 6 years ago

This was working fine until two days ago.

Can you think of anything in your environment that has changed? I am not trying to shift blame, but I need to somehow try and track down the root cause. You are right, that stack trace will not help much :(

Any info you can give will be helpful.

Are you running this on a device or an emulator? Which device / emulator? Which iOS version? etc.....?

joshuatantonflynn commented 6 years ago

I've just looked into client->non-public members->_options and found the following values set to null Browser ClientSecret RedirectUri

But according to the documentation you don't need to set these. I definitely have the correct ID and Domain set

joshuatantonflynn commented 6 years ago

iPhone 7

jerriep commented 6 years ago

Device or emulator? Please be specific. What about the iOS version?

joshuatantonflynn commented 6 years ago

Sorry, Device. 11.4

jerriep commented 6 years ago

OK, I will give attention to this next week. It is 11 PM on a Friday over here.

Thanks for the info so far.

joshuatantonflynn commented 6 years ago

OK, I'll let you know if I solve the issue.

joshuatantonflynn commented 6 years ago

Looks like I figured it out. I went back through my git and saw after my colleague had merged with my code I had to change some iOS properties to get it to build (specifically supported Architectures). Looks like I had also changed Linker Behaviour to Link All. I was working on Droid after merging with him so it was back a few commits. Switched back to iOS and this bug was happening. So I switched the linker behaviour back to Link Framework SDKs Only. It now does not have this problem.

Thanks for the help.

jerriep commented 6 years ago

This is great information and detective work, thank you @joshuatantonflynn

I will work with this information and see whether I can reproduce, and if so, I will update the docs accordingly to make users aware of this. Or perhaps see whether I can avoid the Linker removing the relevant code.