简体   繁体   中英

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

I have set up "Google Identity Platform" and can obtain the access token via firebase-ui web using following code snippet:

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

Now I need to Authenticate users in my ASP NET CORE backend by verifying the access token but I couldn't find any sample.

Is it possible to do it via Google.Apis.Auth.AspNetCore3 library? What is the best solution for it?

Note: I don't want to call the tokeninfo endpoint for every request.

Google.Apis.Auth.AspNetCore3 is not needed. just add the following code:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM