auth0-samples / auth0-xamarin-oidc-samples

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

Xamarin Forms - Error connecting to https://frt-dev.us.auth0.com/.well-known/jwks.json #42

Closed meroag closed 3 years ago

meroag commented 3 years ago

Description

I'm trying to authenticate using SKD version Auth0.OidcClient.Android 3.2.3. and I get error when I call LoginAsync()

System.InvalidOperationException:** 'Error loading discovery document: Error connecting to https://frt-dev.us.auth0.com/.well-known/jwks.json. The type initializer for 'System.Text.Json.JsonSerializer' threw an exception..'

here are my code samples:

[assembly: Dependency(typeof(AuthenticationService))]
namespace FRT_EmpTemp.Droid.LocalServices
{
    public class AuthenticationService: IAuthenticationService
    {
        private Auth0Client _auth0Client;

        public AuthenticationService()
        {
            _auth0Client = new Auth0Client(new Auth0ClientOptions
            {
                Domain = "MY Domain is Writen here",
                ClientId = "And some ID here"
            });
        }

        public async Task<string> Authenticate()
        {
            var res = await _auth0Client.LoginAsync(); // exception is thrown here.
            return res.AccessToken;
        }
    }
}
frederikprijck commented 3 years ago

This is a known issue with the OpenID client we are using that I am looking into. Can you try and see if installing the latest System.Text.Json solves the problem for you?

meroag commented 3 years ago

Yes it works. thanks ;)