我使用的是Asp.Net MVC-5提供的默认模板。启用Google身份验证。我的本地网站带我到谷歌认证页面。但是,当google重定向返回时,在成功的身份验证中,我得到了以下错误:
证书链是由不受信任的权威机构颁发的。
我显式地检查和信任IIS Express站点。
从这篇文章开始,我正确地跟踪了每一步
发布于 2021-01-23 05:24:02
这是一段视频,一步一步的youtube链接到dotnet5命令行设置中google认证mvc的视频.
首先到这里创建凭据.:[https://console.developers.google.com/apis/credentials\](https://console.developers.google.com/apis/credentials%5C)
然后命令行时间:
dotnet new mvc -o MyApplicationName --auth Individual
dotnet add package Microsoft.AspNetCore.Authentication.Google
dotnet user-secrets init
dotnet user-secrets set "Authentication:Google:ClientId" <MyClientIDSecret>
dotnet user-secrets set "Authentication:Google:ClientSecret" <MyClientSecret>
dotnet add package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.AspNetCore.Identity.UI
dotnet tool update --global dotnet-ef
dotnet ef migrations add InitialCreate
dotnet ef database update然后在visual studio或vs代码中打开并更改代码:
就在addControllersWithViews之上:
services.AddAuthentication()
.AddGoogle(options =>
{
IConfigurationSection googleAuthNSection =
Configuration.GetSection("Authentication:Google");
options.ClientId = googleAuthNSection["ClientId"];
options.ClientSecret = googleAuthNSection["ClientSecret"];
});向家庭控制器添加授权添加匿名添加到索引
https://stackoverflow.com/questions/27318921
复制相似问题