google第三方登陆
- 登陆开发者控制台:
console.developer.google.com - 创建项目
Credential
选择web application
Name:demo
Redirect_Uri: http://localhost:5000/signin-google
得到client_id, client_secret
- 认证服务器Startup.cs
services.AddAuthentication()
.AddGoogle(options =>
{
options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
// register your IdentityServer with Google at https://console.developers.google.com
// enable the Google+ API
// set the redirect URI to http://localhost:5000/signin-google
options.ClientId = "copy client ID from Google here";
options.ClientSecret = "copy client secret from Google here";
});
整个过程,先跳转到google,选择google账号,因为在google的开发者账户中设置了跳转地址,所以跳转到我们自己的认证服务器,然后在同意页面选择,最后登陆受我们自己服务器管理的web站点。
本文介绍如何使用 Google 的 OAuth 服务实现第三方登录功能。通过在 Google 开发者平台注册应用并获取凭证,再配置 ASP.NET Core 认证中间件,最终实现用户通过 Google 账户登录自己的 Web 应用。
201

被折叠的 条评论
为什么被折叠?



