临时代码提交
continuous-integration/drone/push Build is passing Details

IRC_NewDev
hang 2024-10-29 18:04:10 +08:00
parent 67667f6438
commit c6c8daaadf
1 changed files with 32 additions and 7 deletions

View File

@ -1,4 +1,5 @@
using Amazon.SecurityToken;
using Amazon.Auth.AccessControlPolicy;
using Amazon.SecurityToken;
using IRaCIS.Application.Contracts;
using IRaCIS.Application.Interfaces;
using IRaCIS.Core.Application.Auth;
@ -15,6 +16,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq;
@ -413,16 +415,39 @@ namespace IRaCIS.Api.Controllers
[HttpGet("User/OAuthCallBack")]
public async Task<IResponseOutput> OAuthCallBack(string type, string code)
{
#region 获取AccessToken
#region 获取AccessTo
var headerDic = new Dictionary<string, string>();
headerDic.Add("code", code);
headerDic.Add("grant_type", "authorization_code");
headerDic.Add("redirect_uri", "http://localhost:6100");
headerDic.Add("scope", "all");
//var headerDic = new Dictionary<string, string>();
//headerDic.Add("code", code);
//headerDic.Add("grant_type", "authorization_code");
//headerDic.Add("redirect_uri", "http://localhost:6100");
//headerDic.Add("scope", "all");
#endregion
#region 客户端凭证方式获取尝试
var client = new RestClient();
var request = new RestRequest("https://logto.test.extimaging.com//oidc/token", Method.Post)
{
RequestFormat = DataFormat.Json
};
////request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
////request.AddParameter("grant_type", "client_credentials");
////request.AddParameter("client_id", clientId);
////request.AddParameter("client_secret", clientSecret);
////request.AddParameter("resource", resource);
////request.AddParameter("scope", scope);
////var response = await client.ExecuteAsync<AuthenticationResponse>(request);
//if (!response.IsSuccessful || response.Data == null)
//{
// throw new InvalidOperationException("Authentication failed.");
//}
#endregion
return ResponseOutput.Ok();
}