According to my understanding, you want to validate the access token. If so, we can use the sdk System.IdentityModel.Tokens
to implement it.
For example
var configurationManager = new ConfigurationManager<OpenIdConnectConfiguration>(
"https://testb2ctenant05.b2clogin.com/testB2CTenant05.onmicrosoft.com/v2.0/.well-known/openid-configuration?p=B2C_1_test",
new OpenIdConnectConfigurationRetriever(), new HttpDocumentRetriever());
CancellationToken ct = default(CancellationToken);
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
var discoveryDocument = await configurationManager.GetConfigurationAsync(ct);
var signingKeys = discoveryDocument.SigningKeys;
var validationParameters = new TokenValidationParameters
{
RequireExpirationTime = true,
RequireSignedTokens = true,
ValidateIssuer = true,
ValidIssuer = discoveryDocument.Issuer,
ValidateIssuerSigningKey = true,
IssuerSigningKeys = signingKeys,
ValidateLifetime = true,
};
var principal = new JwtSecurityTokenHandler()
.ValidateToken(token, validationParameters, out var rawValidatedToken);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…