Пример #1
0
        public ActionResult Refresh(Guid id)
        {
            var dto = _service.Get(id);

            EleUserApiService service = new EleUserApiService();

            var res = service.RefreshToken(dto.RefreshToken);

            if (res == "")
            {
                return(Json(Tools.ResultErr()));
            }

            JObject jo = JObject.Parse(res);

            if (jo["error"] != null)
            {
                return(Json(Tools.ResultErr(jo["error_description"].ToString())));
            }

            dto.AccessToken  = jo["access_token"].ToString();
            dto.RefreshToken = jo["refresh_token"].ToString();
            dto.ExpiresDate  = DateTime.Now.AddSeconds(double.Parse(jo["expires_in"].ToString()));

            _service.Update(dto);

            return(Json(new AjaxResult()
            {
                state = "ok"
            }));
        }
Пример #2
0
        private async Task Auth(Ele_AccountDTO dto)
        {
            var service = new EleUserApiService();

            var res = service.RefreshToken(dto.RefreshToken);

            if (res == "")
            {
                _log.DebugFormat("【更新授权异常】:返回结果空");
                return;
            }

            var jo = JObject.Parse(res);

            if (jo["error"] != null)
            {
                _log.DebugFormat($"【更新授权异常】:{jo["error_description"]}");
                return;
            }

            dto.AccessToken  = jo["access_token"]?.ToString();
            dto.RefreshToken = jo["refresh_token"]?.ToString();
            dto.ExpiresDate  = DateTime.Now.AddSeconds(double.Parse(jo["expires_in"]?.ToString() ?? string.Empty));

            _eleAccountService.Update(dto);
        }