This commit is contained in:
2024-06-07 15:13:19 +08:00
parent 6bbff852fb
commit 39915654b8
17 changed files with 7786 additions and 47 deletions
+8 -6
View File
@@ -16,6 +16,7 @@ namespace FineUIPro.Web
protected void Page_Load(object sender, EventArgs e)
{
this.code = Request.Params["code"];
BLL.ErrLogInfo.WriteLog($"获取code={this.code}");
if (string.IsNullOrEmpty(this.code))
{
Response.Redirect("~/login.aspx");
@@ -37,16 +38,16 @@ namespace FineUIPro.Web
string clientId = "9379ad91-eef9-4956-a1ee-8b04bb3d42c8";
string clientSecret = "iLu8Q~4DRYAn~sMjvO1j.tgRERFWhILvLYRPNc9S";
string grant_type = "authorization_code";
string redirect_url = "http://localhost:6166/ssocallback.aspx";
string redirect_url = "https://fcl-test.basf-ypc.net.cn/ssocallback.aspx";
string scope = "profile openid";
string baseUrl = $" https://login.microsoftonline.com/ecaa386b-c8df-4ce0-ad01740cbdb5ba55/oauth2/v2.0/token";
string baseUrl = $"https://login.microsoftonline.com/{clientId}/oauth2/v2.0/token";
try
{
string postData = $"code={code}&client_id={clientId}&client_secret={clientSecret}&grant_type={grant_type}&redirect_uri={redirect_url}&scope={scope}";
string result = BLL.Common.HttpHelper.HttpPostRequest(baseUrl, postData, string.Empty);
BLL.ErrLogInfo.WriteLog($"请求参数postData={postData}");
string result = BLL.Common.HttpHelper.HttpPost(baseUrl, postData);
BLL.ErrLogInfo.WriteLog($"请求API Result={result}");
var Data = JsonConvert.DeserializeObject<AccessTokenModel>(result);
return Data;
@@ -67,11 +68,12 @@ namespace FineUIPro.Web
try
{
var result = HttpHelper.HttpGetRequest(baseUrl, token.access_token);
BLL.ErrLogInfo.WriteLog($"获取用户信息:{result}");
if (result.IndexOf("sub") > -1)
{
var info = JsonConvert.DeserializeObject<UserTokenModel>(result);
//写入session信息
//写入cookie信息
return info;