app和小程序登录接口

This commit is contained in:
tongfei
2023-10-28 16:47:28 +08:00
parent 25e8a9e30a
commit 12073c36de
20 changed files with 997 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ using System.Net.Http.Headers;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto.Login;
namespace WMS.Web.Core.Help
{
@@ -81,6 +82,36 @@ namespace WMS.Web.Core.Help
return respData;
}
public string PostHttp(string url, LoginAuthorizeRequest reqData)
{
var str = string.Format("client_id={0}&client_secret={1}&grant_type={2}&username={3}&password={4}&scope={5}",
reqData.ClientId, reqData.ClientSecret, reqData.GrantType, reqData.UserName, reqData.Password,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);