单点登录-pc端使用v3版本
This commit is contained in:
@@ -39,4 +39,26 @@ namespace WMS.Web.Core.Dto.Login
|
||||
|
||||
public string Scope { get; set; }
|
||||
}
|
||||
|
||||
public class LoginAuthorizeCodeRequest
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ClientId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ClientSecret { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string GrantType { get; set; }
|
||||
|
||||
public string Code { get; set; }
|
||||
|
||||
public string Scope { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,35 @@ namespace WMS.Web.Core.Help
|
||||
|
||||
}
|
||||
|
||||
public string PostHttp(string url, LoginAuthorizeCodeRequest reqData)
|
||||
{
|
||||
var str = string.Format("client_id={0}&client_secret={1}&grant_type={2}&code={3}&scope={4}",
|
||||
reqData.ClientId, reqData.ClientSecret, reqData.GrantType, reqData.Code,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 PostHttpNoData(string url, string cookieValue = "")
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
|
||||
Reference in New Issue
Block a user