IdentityServer4系列(07)【使用第三方登录】

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站点。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值