GetTokenAsync(RequestTokenModel model, CancellationToken cancellationToken = default) { var systemNow = SystemHelper.SystemTimeNow; //var appService = _serviceProvider.GetService<IApplicationService>(); //appService.CheckValid(model.ClientId, model.GrantType); var userService = _serviceProvider.GetService <IUserService>(); var tokenModel = new TokenModel { ExpireIn = systemNow.AddSeconds(3600).ToTimestamp(), //State = model.State, TokenType = TokenType.AuthTokenType }; switch (model.GrantType) { case GrantType.AuthorizationCode: //case GrantType.AuthorizationCodePKCE: //{ // AuthorizeCodeStorageModel authorizeCodeStorageModel = GetValidCode(model); // var userBasicInfo = GetUserBasicInfoByUserName(authorizeCodeStorageModel.UserName); // tokenModel.AccessToken = JwtHelper.Generate(userBasicInfo, 3600); // tokenModel.RefreshToken = GenerateRefreshToken(userBasicInfo.Id); // break; //} //case GrantType.Implicit: //{ // var userBasicInfo = GetUserBasicInfoByUserName(model.UserName); // tokenModel.AccessToken = JwtHelper.Generate(userBasicInfo, 3600); // break; //} case GrantType.ResourceOwner: { CheckValidSignIn(model.UserName, model.Password); var userBasicInfo = GetUserBasicInfoByUserName(model.UserName); tokenModel.AccessToken = JwtHelper.Generate(userBasicInfo, 3600); tokenModel.RefreshToken = GenerateRefreshToken(userBasicInfo.Id); break; } case GrantType.RefreshToken: { CheckValidRefreshToken(model.RefreshToken); tokenModel.RefreshToken = model.RefreshToken; var userBasicInfo = GetUserBasicInfoByRefreshToken(model.RefreshToken); tokenModel.AccessToken = JwtHelper.Generate(userBasicInfo, 3600); break; } } return(Task.FromResult(tokenModel)); }