Skip to content

Instantly share code, notes, and snippets.

@jerriep
Created January 16, 2016 11:44
Show Gist options
  • Select an option

  • Save jerriep/93194eb2da854068cf0f to your computer and use it in GitHub Desktop.

Select an option

Save jerriep/93194eb2da854068cf0f to your computer and use it in GitHub Desktop.
Store tokens in ASP.NET 5
app.UseTwitterAuthentication(options =>
{
options.ConsumerKey = Configuration["Authentication:Twitter:ConsumerKey"];
options.ConsumerSecret = Configuration["Authentication:Twitter:ConsumerSecret"];
options.Events = new TwitterEvents
{
OnCreatingTicket = context =>
{
var claimsIdentity = context.Principal.Identity as ClaimsIdentity;
if (claimsIdentity != null)
{
claimsIdentity.AddClaim(new Claim("urn:twitter:accesstoken", context.AccessToken));
claimsIdentity.AddClaim(new Claim("urn:twitter:accesstokensecret", context.AccessTokenSecret));
}
return Task.FromResult(true);
}
};
});
@VijayBhatter
Copy link

Hi,

Thank you for posting this. But could not find an equivalent in Facebook. Do I need to implement IOAuthEvents as they have not provided the default implementation yet. Somewhere I read they are saying we can hook into to options.Events.CreatingTickets event but I am not sure how to do that.

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment