public override Task <TokenResponseDTO> Refresh(TokenRefreshRequestDTO request, ServerCallContext context) { return(Task.Run(() => { TokenResponseDTO response = new TokenResponseDTO(); RefreshTokenProvider refresh = new RefreshTokenProvider(request.Appid, request.RefreshToken); if (!refresh.Refresh()) { response.RetMsg = refresh.PromptInfo.CustomMessage; response.RetCode = refresh.PromptInfo.ResultType <= 0 ? "0500" : ((int)refresh.PromptInfo.ResultType).ToString().PadLeft(4, '0'); return response; } response.RetCode = "0000"; response.RetMsg = "ok"; response.Data = new TokenResponseDTO.Types.Result { RefreshToken = refresh.OAuthUser.Refresh_Token, Expires = refresh.OAuthUser.Expire_In, Openid = refresh.OAuthUser.Open_Id, RefreshExpires = refresh.OAuthUser.Refresh_Expire_In, Token = refresh.OAuthUser.Token }; return response; })); }
/// <summary> /// 刷新授权Token /// </summary> /// <param name="appid">应用账号</param> /// <param name="refresh_token">刷新令牌</param> /// <param name="grant_type">授权类型=refresh_token</param> /// <returns></returns> public ActionResult RefreshToken(string appid, string refresh_token, string grant_type) { JsonResult jsonRes = null; RefreshTokenProvider refresh = new RefreshTokenProvider(appid, refresh_token); if (!refresh.Refresh()) { jsonRes = FailResult(refresh.PromptInfo.CustomMessage, (int)refresh.PromptInfo.ResultType); jsonRes.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(jsonRes); } jsonRes = SuccessResult(refresh.OAuthUser); jsonRes.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(jsonRes); }
public ResponseResult <TokenResponseDTO> Refresh(TokenRefreshRequestDTO request) { RefreshTokenProvider refresh = new RefreshTokenProvider(request.Appid, request.RefreshToken); if (!refresh.Refresh()) { return(Fail <TokenResponseDTO>(refresh.PromptInfo.CustomMessage)); } TokenResponseDTO response = new TokenResponseDTO { RefreshToken = refresh.OAuthUser.Refresh_Token, Expires = refresh.OAuthUser.Expire_In, Openid = refresh.OAuthUser.Open_Id, RefreshExpires = refresh.OAuthUser.Refresh_Expire_In, Token = refresh.OAuthUser.Token }; return(Success(response)); }