Skip to content

Instantly share code, notes, and snippets.

@sadrakgunadi
Created February 11, 2019 09:50
Show Gist options
  • Save sadrakgunadi/83e14d7ce65d2419db88cada84c075c7 to your computer and use it in GitHub Desktop.
Save sadrakgunadi/83e14d7ce65d2419db88cada84c075c7 to your computer and use it in GitHub Desktop.
Token Validation Parameter
TokenValidationParameters tvp = new TokenValidationParameters() {
ValidateActor = false,
// check the profile ID
ValidateAudience = true,
// check the client ID
ValidAudience = CLIENT_ID,
ValidateIssuer = true,
// check token came from Google
ValidIssuers = new List < string > {
"accounts.google.com",
"https://accounts.google.com"
},
ValidateIssuerSigningKey = true,
RequireSignedTokens = true,
IssuerSigningKeys = certificates.Values.Select(x = >new X509SecurityKey(x)),
IssuerSigningKeyResolver = (token, securityToken, kid, validationParameters) = >{
return certificates.Where(x = >x.Key.ToUpper() == kid.ToUpper()).Select(x = >new X509SecurityKey(x.Value));
},
ValidateLifetime = true,
RequireExpirationTime = true,
ClockSkew = TimeSpan.FromHours(13)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment