"
 
 
 
ASP.NET (snapshot 2017) Microsoft documentation and samples

Configuring Twitter authentication

By Valeriy Novytskyy and Rick Anderson

This tutorial shows you how to enable your users to sign in with their Twitter account using a sample ASP.NET Core 2.0 project created on the previous page.

Create the app in Twitter

Twitter Application Management open in Microsoft Edge
Twitter Application Management open in Microsoft Edge
Create an application page
Create an application page
Details tab on Application page
Details tab on Application page

Storing Twitter ConsumerKey and ConsumerSecret

Link sensitive settings like Twitter Consumer Key and Consumer Secret to your application configuration using the Secret Manager. For the purposes of this tutorial, name the tokens Authentication:Twitter:ConsumerKey and Authentication:Twitter:ConsumerSecret.

These tokens can be found on the Keys and Access Tokens tab after creating your new Twitter application:

Keys and Access Tokens tab
Keys and Access Tokens tab

Configure Twitter Authentication

The project template used in this tutorial ensures that Microsoft.AspNetCore.Authentication.Twitter package is already installed.

ASP.NET Core 2.x

Add the Twitter service in the ConfigureServices method in Startup.cs file:

[!INCLUDEdefault settings configuration]

ASP.NET Core 1.x

Add the Twitter middleware in the Configure method in Startup.cs file:


See the TwitterOptions API reference for more information on configuration options supported by Twitter authentication. This can be used to request different information about the user.

Sign in with Twitter

Run your application and click Log in. An option to sign in with Twitter appears:

Web application: User not authenticated
Web application: User not authenticated

Clicking on Twitter redirects to Twitter for authentication:

Twitter authentication page
Twitter authentication page

After entering your Twitter credentials, you are redirected back to the web site where you can set your email.

You are now logged in using your Twitter credentials:

Web application: User authenticated
Web application: User authenticated

Troubleshooting

Next steps





Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23
Link to this page: //www.vb-net.com/AspNet-DocAndSamples-2017/aspnetcore/security/authentication/social/twitter-logins.htm
<SITEMAP>  <MVC>  <ASP>  <NET>  <DATA>  <KIOSK>  <FLEX>  <SQL>  <NOTES>  <LINUX>  <MONO>  <FREEWARE>  <DOCS>  <ENG>  <CHAT ME>  <ABOUT ME>  < THANKS ME>