小编gij*_*ijs的帖子

如何在ASP.NET Boilerplate中设置社交登录?

我正在尝试通过Google对用户进行身份验证。我正在使用Vue的ASP.NET Core的ABP启动模板。

到目前为止,这是我所做的:

GoogleAuthProviderApi在Web.Core中创建了一个:

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication.Google;
using Newtonsoft.Json.Linq;

namespace Mindbus.MindbooksSEO.Authentication.External.Google
{
    public class GoogleAuthProviderApi : ExternalAuthProviderApiBase
    {
        public const string Name = "Google";

        public override async Task<ExternalAuthUserInfo> GetUserInfo(string accessCode)
        {
            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OAuth middleware");
                client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
                client.Timeout = TimeSpan.FromSeconds(30);
                client.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB

                var request = new HttpRequestMessage(HttpMethod.Get, GoogleDefaults.UserInformationEndpoint);
                request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessCode);

                var response = …
Run Code Online (Sandbox Code Playgroud)

c# authentication configuration asp.net-core aspnetboilerplate

5
推荐指数
1
解决办法
2166
查看次数