diff --git a/IRaCIS.Core.API/Controllers/ExtraController.cs b/IRaCIS.Core.API/Controllers/ExtraController.cs index 67f8b5a7c..25ca48989 100644 --- a/IRaCIS.Core.API/Controllers/ExtraController.cs +++ b/IRaCIS.Core.API/Controllers/ExtraController.cs @@ -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 OAuthCallBack(string type, string code) { - #region 获取AccessToken + #region 获取AccessTo - var headerDic = new Dictionary(); - 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(); + //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(request); + + //if (!response.IsSuccessful || response.Data == null) + //{ + // throw new InvalidOperationException("Authentication failed."); + //} + #endregion + return ResponseOutput.Ok(); }