public async Task <IActionResult> GetToken([FromForm] ReqTokenDto reqToken) { ResModel <ResTokenDto> res = new ResModel <ResTokenDto>(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } HttpContext context = _httpContextAccessor.HttpContext; IActionResult response = Unauthorized(); //var user = AuthenticateUser(login); ResTokenDto token = new ResTokenDto(); try { //验证客户端应用唯一编号,调用时采用MD5加密传输 //var crpid = DesHelper.Decrypt(reqToken.corp_id); if (_configuration["Jwt:client_id"] != reqToken.client_id || _configuration["Jwt:client_secret"] != reqToken.client_secret || Md5Helper.Get32MD5One(_configuration["Jwt:corp_id"]).ToLower() != reqToken.corp_id) { res.success = "false"; res.resultMessage = "无权限访问!"; } else { if (reqToken.response_type == "token") { //记录调用获取Access token接口 res = await _iunion.GetToken(reqToken, context); if (res.success == "true") { var tokenString = GenerateJSONWebToken(reqToken); token = new ResTokenDto { access_token = tokenString, time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), expire_in = DateTime.Now.AddHours(24).ToString("yyyy-MM-dd HH:mm:ss"), state = reqToken.state }; res.success = "true"; res.result = token; } } else { res.success = "false"; res.resultMessage = "无权限访问!"; } } response = Ok(res); } catch (Exception ex) { return(Ok(res.GetRes("false", ex.Message, null))); } return(response); }