簡體   English   中英

如何使用 Google.Apis.Auth.AspNetCore3 在 C# 中驗證 Google Identity Platform 的完整性?

[英]How to Verify the integrity of the Google Identity Platform in C# with Google.Apis.Auth.AspNetCore3?

我已經設置了“Google Identity Platform”並且可以使用以下代碼片段通過 firebase-ui web 獲取訪問令牌:

 user.getIdToken().then(function (accessToken) {
    console.log(accessToken);
  });

現在我需要通過驗證訪問令牌來驗證我的 ASP NET CORE 后端中的用戶,但我找不到任何示例。

是否可以通過 Google.Apis.Auth.AspNetCore3 庫來做到這一點? 什么是最好的解決方案?

注意:我不想為每個請求調用 tokeninfo 端點。

不需要 Google.Apis.Auth.AspNetCore3。 只需添加以下代碼:

        builder.Services
            .AddAuthentication()
            .AddJwtBearer("GoogleIdentityPlatformScheme", bearerOptions =>
            {
                bearerOptions.Authority = "https://securetoken.google.com/FIREBASE_PROJECT_ID";
                bearerOptions.Audience = "FIREBASE_PROJECT_ID";
            });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM