client is winform , .net framework 4.6.1, used servicestack 5.13.2,
service is .net core 6.0, used servicestack 5.13.2, works fine, after servicestack upgrade to 6.0,
client call the service get error.
private string GetBearerToken(string url)
{
var authClient = new JsonServiceClient(url);
var bearerToken = authClient.Send(new Authenticate
{
provider = "credentials",
UserName = userName,
Password = userName + "123456",
}).BearerToken;
return bearerToken;
}
{"ResponseStatus":{"ErrorCode":"Unauthorized","Message":"Invalid Username or Password","StackTrace":"[Authenticate: 2022/1/29 0:54:14]:\n[REQUEST: {provider:credentials,UserName:weixinyb,Password:weixinyb87065701}]\r\nServiceStack.HttpError: Invalid Username or Password\r\n at ServiceStack.Auth.CredentialsAuthProvider.AuthenticateAsync(IServiceBase authService, IAuthSession session, String userName, String password, String referrerUrl, CancellationToken token) in C:\\BuildAgent\\work\\3481147c480f4a2f\\src\\ServiceStack\\Auth\\CredentialsAuthProvider.cs:line 178\r\n at ServiceStack.Auth.CredentialsAuthProvider.AuthenticateAsync(IServiceBase authService, IAuthSession session, Authenticate request, CancellationToken token) in C:\\BuildAgent\\work\\3481147c480f4a2f\\src\\ServiceStack\\Auth\\CredentialsAuthProvider.cs:line 124\r\n at ServiceStack.Auth.AuthenticateService.AuthenticateAsync(Authenticate request, String provider, IAuthSession session, IAuthProvider oAuthConfig, CancellationToken token) in C:\\BuildAgent\\work\\3481147c480f4a2f\\src\\ServiceStack\\Auth\\AuthenticateService.cs:line 476\r\n at ServiceStack.Auth.AuthenticateService.PostAsync(Authenticate request) in C:\\BuildAgent\\work\\3481147c480f4a2f\\src\\ServiceStack\\Auth\\AuthenticateService.cs:line 280\r\n at ServiceStack.Host.ServiceRunner`1.ExecuteAsync(IRequest req, Object instance, TRequest requestDto) in C:\\BuildAgent\\work\\3481147c480f4a2f\\src\\ServiceStack\\Host\\ServiceRunner.cs:line 154\r\n","Errors":[]}}
I had try changed UseTokenCookie to false, also get the error.
new JwtAuthProvider(AppSettings) {
RequireSecureConnection =false,
AuthKey = AesUtils.CreateKey(),
ExpireTokensIn = TimeSpan.FromDays(365), // JWT Token Expiry
ExpireRefreshTokensIn = TimeSpan.FromDays(365), // Refresh Token Expiry
UseTokenCookie = false, //Revert to Bearer Token Responses
},
how to solve it?