Auth0.OidcClient.iOS LoginAsync freezes everything

I am trying to create a login page for iOS in Xamarin.Forms with the Auth0 API but every time I call my login method, it freezes at “client.LoginAsync()”. had this working at first but suddenly I was unable to retrieve a login page and the iPhone screen froze. The only output I receive is: Thread started. I thought it might be due to incorrect callback URL configurations or mixed client IDs but I don’t think this is the case. Here is my iOS code:

using Auth0.OidcClient;
using System.Diagnostics;
using IdentityModel.OidcClient;
using System.Threading.Tasks;
using IdentityModel.OidcClient.Browser;
using App3.Data;
using App3.Models;

[assembly: Xamarin.Forms.Dependency(typeof(App3.iOS.Auth))]
namespace App3.iOS
    public class Auth : IAuthentication
        async public Task<User> Login()
            Auth0Client client = new Auth0Client(new Auth0ClientOptions

                Domain = "{domain name}",
                ClientId = "{client id}",

            Debug.WriteLine("This prints");
            var loginResult = await client.LoginAsync(new LoginRequest());
            Debug.WriteLine("This never prints");
            if (loginResult.IsError)
                Debug.WriteLine($"An error occurred during login: {loginResult.Error}");
                return null;
            Debug.WriteLine($"id_token: {loginResult.IdentityToken}");
            Debug.WriteLine($"access_token: {loginResult.AccessToken}");
            Debug.WriteLine($"name: {loginResult.User.FindFirst(c => c.Type == "name")?.Value}");
            Debug.WriteLine($"email: {loginResult.User.FindFirst(c => c.Type == "email")?.Value}");
            User user = new User();
   = 0;
   = loginResult.User.FindFirst(c => c.Type == "name")?.Value;
   = loginResult.User.FindFirst(c => c.Type == "email")?.Value;
            //user.token = new Token(loginResult.IdentityToken, loginResult.AccessToken);
            return user;

This is what my Info.plist looks like:


Any help or ideas as to what may be causing this problem would be greatly appreciated. I have been stuck on this problem for a while now.

FIX: The problem was not the LoginAsync method but my optimization of threads in calling the function. If anyone else has this problem simply make sure you are “awaiting” for the task to finish instead of waiting for its .Result. Hope this is useful for beginners to threading in C# such as myself.

1 Like

Glad you have figured it out!