test: 测试qq回调

This commit is contained in:
橙子
2024-01-05 23:05:13 +08:00
parent 310e6749b8
commit 093b5a7a7b
4 changed files with 67 additions and 26 deletions

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Quartz.Logging;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
namespace Yi.Framework.Bbs.Application.Services.Authentication
{
public class QQAuthService : IRemoteService, ITransientDependency
{
private HttpContext HttpContext { get; set; }
private ILogger<QQAuthService> _logger;
public QQAuthService(IHttpContextAccessor httpContextAccessor, ILogger<QQAuthService> logger)
{
_logger = logger;
HttpContext = httpContextAccessor.HttpContext ?? throw new ApplicationException("未注册Http");
}
[HttpGet("/auth/qq")]
public async Task AuthQQAsync()
{
var data = await HttpContext.AuthenticateAsync("QQ");
_logger.LogError($"QQ回调信息:{Newtonsoft.Json.JsonConvert.SerializeObject(data)}");
_logger.LogError($"QQ回调身份:{Newtonsoft.Json.JsonConvert.SerializeObject(data.Principal)}");
}
}
}