Skip to content

Instantly share code, notes, and snippets.

@kzelda
Created February 19, 2020 11:58
Show Gist options
  • Select an option

  • Save kzelda/26d72c3dc2b9b0d07f3079b959cfd189 to your computer and use it in GitHub Desktop.

Select an option

Save kzelda/26d72c3dc2b9b0d07f3079b959cfd189 to your computer and use it in GitHub Desktop.
Decrypt Identity OAuth Bearer Token using C#
public Dictionary<string,string> DecryptIdentityOAuthToken(string token)
{
var ticket = Startup.OAuthServerOptions.AccessTokenFormat.Unprotect(token);
var claims = new Dictionary<string,string>();
if (ticket != null && ticket.Identity != null && ticket.Identity.IsAuthenticated)
{
foreach(var claim in ticket.Identity.Claims)
{
claims.Add(claim.Type, claim.Value);
}
}
return claims;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment