相关疑难解决方法(0)

验证Google Id令牌

我正在使用ASP.NET Core为Android客户端提供API.Android以Google帐户登录,并将ID令牌JWT作为承载令牌传递给API.我有应用程序工作,它确实通过了身份验证检查,但我不认为它正在验证令牌签名.

根据Google的文档,我可以将此网址称为 https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=XYZ123,但我无法在服务器端找到相应的挂钩来执行此操作.另外根据Google文档,我可以以某种方式使用客户端访问API来执行此操作,而无需每次都调用服务器.

我的配置代码:

app.UseJwtBearerAuthentication( new JwtBearerOptions()
{

    Authority = "https://accounts.google.com",
    Audience = "hiddenfromyou.apps.googleusercontent.com",
    TokenValidationParameters = new TokenValidationParameters()
    {
        ValidateAudience = true,
        ValidIssuer = "accounts.google.com"
    },
    RequireHttpsMetadata = false,
    AutomaticAuthenticate = true,
    AutomaticChallenge = false,
});
Run Code Online (Sandbox Code Playgroud)

如何让JWTBearer中间件验证签名?我已经接近放弃使用MS中间件并自行推出.

c# google-api jwt google-oauth asp.net-core

15
推荐指数
3
解决办法
1万
查看次数

标签 统计

asp.net-core ×1

c# ×1

google-api ×1

google-oauth ×1

jwt ×1