Created
January 16, 2016 11:44
-
-
Save jerriep/93194eb2da854068cf0f to your computer and use it in GitHub Desktop.
Store tokens in ASP.NET 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } | |
| }; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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