public AuthorizeResponse Authorize([FromBody] AuthorizeRequest authorizeRequest) { try { var value = RsaHelper .DecryptString(authorizeRequest.EncryptedToken, _asymmetricEncryptionSettings.PublicKey, false, true); var token = _tokenService.GetTokenByTypeAndValue(AccessTokenType, value); var claims = new List <Claim> { new Claim("sub", token.Author) }; var identity = new ClaimsIdentity(JwtBearerDefaults.AuthenticationScheme); identity.AddClaims(claims); HttpContext.User = new ClaimsPrincipal(identity); _tokenService.Delete(token.Id); return(new AuthorizeResponse()); } catch (Exception ex) { return(new AuthorizeResponse { Success = false, Message = ex.Message }); } }