刷新token方法优化
This commit is contained in:
@@ -61,4 +61,26 @@ namespace WMS.Web.Core.Dto.Login
|
||||
|
||||
public string Scope { get; set; }
|
||||
}
|
||||
|
||||
public class LoginAuthorizeRefreshTokenRequest
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ClientId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ClientSecret { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string GrantType { get; set; }
|
||||
|
||||
public string RefreshToken { get; set; }
|
||||
|
||||
public string Scope { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +143,35 @@ namespace WMS.Web.Core.Help
|
||||
|
||||
}
|
||||
|
||||
public string PostHttp(string url, LoginAuthorizeRefreshTokenRequest reqData)
|
||||
{
|
||||
var str = string.Format("client_id={0}&client_secret={1}&grant_type={2}&refresh_token={3}&scope={4}",
|
||||
reqData.ClientId, reqData.ClientSecret, reqData.GrantType, reqData.RefreshToken, reqData.Scope);
|
||||
ASCIIEncoding encoding = new ASCIIEncoding();
|
||||
byte[] byte1 = encoding.GetBytes(str);
|
||||
HttpContent httpContent = new StringContent(str);
|
||||
httpContent.Headers.Expires = DateTime.Now;
|
||||
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
|
||||
httpContent.Headers.ContentLength = byte1.Length;
|
||||
httpContent.Headers.ContentType.CharSet = "utf-8";
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.BaseAddress = new Uri(url);
|
||||
httpClient.Timeout = new TimeSpan(0, 0, 10);
|
||||
HttpResponseMessage response = httpClient.PostAsync(url, httpContent).Result;
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var resData = response.Content.ReadAsStringAsync().Result;
|
||||
return resData;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var resData = response.Content.ReadAsStringAsync().Result;
|
||||
return resData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public string GetHttpOut(string url, LoginOutAuthorizeRequest reqData)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user