Hello,
I have reworked our API to new ServiceStack v8 and migrated it to IdentityAuth.
In typescript, everything works fine after updating typescript client, but we also have older .NET Framework 4.7.2 library, that connects to these services.
Unfortunately, It seems that JsonServiceClient is not compatibile with new authentication routes. When I call client.ApiAsync(new Authenticate {...});
, I get “Method Not Allowed” error. If I try the same in new project targeting .NET 8 with JsonApiClient, everything works fine. Then, if I try it in .NET 8 with JsonServiceClient, it also doesn’t work with the same error.
Steps to reproduce:
- Download any .NET 8 template, like react-spa.
- Add new console project targeting .NET 4.7.2, or even .NET 8.0, doesn’t really matter.
- Install Servicestack.Client
- This code doesn’t work, both calls return “Method not allowed”:
var client = new JsonServiceClient("https://localhost:5001");
try
{
// calling client.PostAsync has same result
var registerResult = await client.ApiAsync(new Register()
{
UserName = "test11@email.com",
Email = "test11@email.com",
Password = "p@55wOrd",
ConfirmPassword = "p@55wOrd",
DisplayName = "Test User",
FirstName = "Test",
LastName = "Next"
});
// calling client.PostAsync has same result
var authResult = await client.ApiAsync(new Authenticate()
{
provider = "credentials",
UserName = "test11@email.com",
Password = "p@55wOrd",
RememberMe = true
});
}
catch (Exception ex)
{
//...
}
- This code works (requires .NET 6.0+ which I cannot use unfortunatelly):
var client = new JsonApiClient("https://localhost:5001");
try
{
var registerResult = await client.ApiAsync(new Register()
{
UserName = "test11@email.com",
Email = "test11@email.com",
Password = "p@55wOrd",
ConfirmPassword = "p@55wOrd",
DisplayName = "Test User",
FirstName = "Test",
LastName = "Next"
});
// Need to change EmailConfirmed to 1 in dabase to succesffully login.
var authResult = await client.ApiAsync(new Authenticate()
{
provider = "credentials",
UserName = "test11@email.com",
Password = "p@55wOrd",
RememberMe = true
});
}
catch (Exception ex)
{
//...
}
Would it be possible to add support for these new Authenticate/Register methods into JsonServiceClient? Or is there a way how to make it work?
Thank you for your response.