Skip to content

Instantly share code, notes, and snippets.

@AnnejanBarelds
Created March 4, 2020 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnnejanBarelds/3cbb98635229c95669d9f17735372281 to your computer and use it in GitHub Desktop.
Save AnnejanBarelds/3cbb98635229c95669d9f17735372281 to your computer and use it in GitHub Desktop.
private string GetJwtTokenProof(X509Certificate2 signingCert, string appId)
{
var notBefore = DateTime.Now;
var expires = notBefore.AddMinutes(10);
var handler = new JwtSecurityTokenHandler();
var credentials = new X509SigningCredentials(signingCert);
var jwtToken = handler.CreateJwtSecurityToken(appId, "https://graph.windows.net", null, notBefore, expires, null, credentials);
return handler.WriteToken(jwtToken);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment