Startup Error when using JWTAuthProvider

Hi

I am receiving this Startup error, but not clear what I can do about it.

System.NullReferenceException: Object reference not set to an instance of an object.
   at ServiceStack.Auth.JwtAuthProviderReader.Register(IAppHost appHost, AuthFeature feature) in /opt/lib/teamcity-agent/work/d09206570215629/src/ServiceStack/Auth/JwtAuthProviderReader.cs:line 552
   at ServiceStack.EnumerableExtensions.Each[T](IEnumerable`1 values, Action`1 action) in /opt/lib/teamcity-agent/work/d09206570215629/src/ServiceStack.Common/EnumerableExtensions.cs:line 30
   at ServiceStack.AuthFeature.Register(IAppHost appHost) in /opt/lib/teamcity-agent/work/d09206570215629/src/ServiceStack/AuthFeature.cs:line 132
   at ServiceStack.ServiceStackHost.LoadPluginsInternal(IPlugin[] plugins) in /opt/lib/teamcity-agent/work/d09206570215629/src/ServiceStack/ServiceStackHost.cs:line 890
   at ServiceStack.Auth.JwtAuthProviderReader.Register(IAppHost appHost, AuthFeature feature) in /opt/lib/teamcity-agent/work/d09206570215629/src/ServiceStack/Auth/JwtAuthProviderReader.cs:line 552
   at ServiceStack.EnumerableExtensions.Each[T](IEnumerable`1 values, Action`1 action) in /opt/lib/teamcity-agent/work/d09206570215629/src/ServiceStack.Common/EnumerableExtensions.cs:line 30
   at ServiceStack.AuthFeature.Register(IAppHost appHost) in /opt/lib/teamcity-agent/work/d09206570215629/src/ServiceStack/AuthFeature.cs:line 132
   at ServiceStack.ServiceStackHost.LoadPluginsInternal(IPlugin[] plugins) in /opt/lib/teamcity-agent/work/d09206570215629/src/ServiceStack/ServiceStackHost.cs:line 890

It seems something with the JwtAuthProvider. I have following code in Configure:

		Plugins.Add(new AuthFeature(() => new AuthUserSession(),
			new IAuthProvider[]
			{
				new JwtAuthProviderReader
				{
					HashAlgorithm = "RS256",
#if (DEBUG)
					RequireSecureConnection = false,
#endif
					PublicKeyXml = publicKeyXml
				},
			}));

So I am only getting the JWT token in, it is provided by another microservice.

Thanks for having a look at it.

If you do not need to use ConvertSessionToTokenService and GetAccessTokenService then you can add empty ServiceRoutes dictionary to JwtAuthProviderReader initialization to avoid this exception.

Plugins.Add(new AuthFeature(() => new AuthUserSession(),
    new IAuthProvider[]
    {
        new JwtAuthProviderReader
        {
            HashAlgorithm = "RS256",
#if (DEBUG)
            RequireSecureConnection = false,
#endif
            PublicKeyXml = publicKeyXml,
            ServiceRoutes = new Dictionary<Type, string[]>()
        }
}));

If you need the services mentioned above then you shoud use JwtAuthProvider instead of JwtAuthProviderReader you’ve passed to AuthFeature constructor

Thanks! I added the empty ServiceRoutes and the startup error went away.
I don’t need JwtAuthProvider because this is hosted on another micro service.