JWT IdentityAuth CreateRefreshTokenAsync method not found

Hi,

Using ServiceStack 8.8, ASP.NET Core 9.0.7 and Entity Framework Core 9.0.7

I’ve configured JwtAuth with EnableRefreshToken = true

Application User implements IRequireRefreshToken

var authFeature = new AuthFeature( IdentityAuth.For<ApplicationUser, ApplicationRole>( options =>
{
    options.CredentialsAuth();
    options.JwtAuth( jwtOptions =>
    {
        jwtOptions.EnableRefreshToken = true;
        jwtOptions.IncludeConvertSessionToTokenService = true;
        jwtOptions.InvalidateRefreshTokenOnLogout = true;
    });
    options.SessionFactory = () => new CustomUserSession();
} ) )

Everything works fine until the IdentityJwtAuthProvider tries to create the refresh token (CreateRefreshTokenAsync) and throws a missing method exception. Stack trace below

Method not found: 'System.Threading.Tasks.Task`1<Int32> Microsoft.EntityFrameworkCore.RelationalQueryableExtensions.ExecuteUpdateAsync(System.Linq.IQueryable`1<!!0>, System.Linq.Expressions.Expression`1<System.Func`2<Microsoft.EntityFrameworkCore.Query.SetPropertyCalls`1<!!0>,Microsoft.EntityFrameworkCore.Query.SetPropertyCalls`1<!!0>>>, System.Threading.CancellationToken)'.
System.MissingMethodException: Method not found: 'System.Threading.Tasks.Task`1<Int32> Microsoft.EntityFrameworkCore.RelationalQueryableExtensions.ExecuteUpdateAsync(System.Linq.IQueryable`1<!!0>, System.Linq.Expressions.Expression`1<System.Func`2<Microsoft.EntityFrameworkCore.Query.SetPropertyCalls`1<!!0>,Microsoft.EntityFrameworkCore.Query.SetPropertyCalls`1<!!0>>>, System.Threading.CancellationToken)'.
   at ServiceStack.Auth.IdentityJwtAuthProvider`3.<>c__DisplayClass113_0.<<CreateRefreshTokenAsync>g__UpdateUser|0>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at ServiceStack.Auth.IdentityJwtAuthProvider`3.<>c__DisplayClass113_0.<CreateRefreshTokenAsync>g__UpdateUser|0(DbContext dbContext)
   at ServiceStack.Auth.IdentityJwtAuthProvider`3.CreateRefreshTokenAsync(TUser user, IRequest req) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack.Extensions/Auth/IdentityJwtAuthProvider.cs:line 603
   at ServiceStack.Auth.IdentityJwtAuthProvider`3.CreateRefreshTokenAsync(TUser user, IRequest req) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack.Extensions/Auth/IdentityJwtAuthProvider.cs:line 603
   at ServiceStack.Auth.IdentityJwtAuthProvider`3.ExecuteAsync(AuthFilterContext authContext) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack.Extensions/Auth/IdentityJwtAuthProvider.cs:line 428
   at ServiceStack.Auth.AuthenticateService.PostAsync(Authenticate request) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Auth/AuthenticateService.cs:line 381
   at ServiceStack.Host.ServiceRunner`1.ExecuteAsync(IRequest req, Object instance, TRequest requestDto) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Host/ServiceRunner.cs:line 149

The ExecuteUpdateAsync and other methods have been moved from RelationalQueryableExtensions to EntityFrameworkQueryableExtensions in .NET 9.

Any ideas on timing on the availability of a .NET 9 ServiceStack version?

ServiceStack only includes platform specific builds for LTS versions, so the next platform upgrade will be .NET 10 LTS, when it’s released later this year.

You may be able to copy and create your own IdentityJwtAuthProvider.cs updated to support .NET 9 APIs.

Thanks. I’ll have a look at creating a copy