initFCL
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
using BLL;
|
||||
using BLL.Common;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace FineUIPro.Web
|
||||
{
|
||||
public partial class ssocallback : System.Web.UI.Page
|
||||
{
|
||||
private string code = string.Empty;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.code = Request.Params["code"];
|
||||
if (string.IsNullOrEmpty(this.code))
|
||||
{
|
||||
Response.Redirect("~/login.aspx");
|
||||
return;
|
||||
}
|
||||
GetAccessToken(this.code);
|
||||
}
|
||||
|
||||
private AccessTokenModel GetAccessToken(string _code)
|
||||
{
|
||||
string clientId = "";
|
||||
string clientSecret = "";
|
||||
string grant_type = "authorization_code";
|
||||
string redirect_url = "http://localhost:6166/ssocallback.aspx";
|
||||
string scope = "profile openid";
|
||||
string baseUrl = $" https://login.microsoftonline.com/ecaa386b-c8df-4ce0-ad01740cbdb5ba55/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);
|
||||
|
||||
var Data = JsonConvert.DeserializeObject<AccessTokenModel>(result);
|
||||
|
||||
return Data;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ErrLogInfo.WriteLog(ex.Message);
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void getUserInfo(string _code)
|
||||
{
|
||||
var objData = GetAccessToken(_code);
|
||||
if (objData == null)
|
||||
{
|
||||
//退出去login页面
|
||||
return;
|
||||
}
|
||||
string baseUrl = "https://graph.microsoft.com/oidc/userinfo";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user