【问题标题】:.NET Core google token validation middleware.NET Core 谷歌令牌验证中间件
【发布时间】:2017-04-09 23:10:23
【问题描述】:

我有使用 Angularjs 和 .Net Core WebAPI 后端编写的客户端应用程序。用户使用我们获取令牌的 Google 登录进行身份验证。此令牌与必须验证的每个 API 请求一起发送到后端。

是否有中间件或者我如何创建中间件来验证令牌?

【问题讨论】:

    标签: .net-core


    【解决方案1】:

    是的,有:Microsoft.AspNetCore.Authentication.Google

    您可以安装:

    dotnet 添加包 Microsoft.AspNetCore.Authentication.Google

    然后在你的startup.cs中配置中间件:

    app.UseGoogleAuthentication(new GoogleOptions()
    {
        ClientId = Configuration["Authentication:Google:ClientId"],
        ClientSecret = Configuration["Authentication:Google:ClientSecret"]
    });
    

    我建议您在此处阅读非常有用且易于遵循的 Microsoft ASP.NET 核心社交身份验证指南:

    https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/

    以及此处的 Google 特定演练:

    https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins

    【讨论】:

      猜你喜欢
      • 2020-10-25
      • 2021-06-27
      • 2019-03-23
      • 2020-02-05
      • 2022-10-19
      • 2018-08-03
      • 2020-12-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多