Home

Awesome

This example illustrates how to use Express 4.x and Passport to sign users in with Twitter. Use this example as a starting point for your own web applications.

Quick Start

To get started with this example, clone the repository and install the dependencies.

$ git clone git@github.com:passport/express-4.x-twitter-example.git
$ cd express-4.x-twitter-example
$ npm install

This example requires credentials from Twitter, which can be obtained by creating an app in the developer portal's App page. The callback URL of the app should be set to: http://localhost:3000/oauth/callback/twitter.com

Once credentials have been obtained, create a .env file and add the following environment variables:

TWITTER_CONSUMER_KEY={{INSERT_API_KEY_HERE}}
TWITTER_CONSUMER_SECRET={{INSERT_API_SECRET_KEY_HERE}}

Start the server.

$ npm start

Navigate to http://localhost:3000.

Overview

This example illustrates how to use Passport and the passport-twitter strategy within an Express application to sign users in with Twitter.

The example builds upon the scaffolding created by Express generator, and uses EJS as a view engine and plain CSS for styling. This scaffolding was generated by executing:

$ express --view ejs express-4.x-twitter-example

The example uses SQLite for storing user accounts. SQLite is a lightweight database that works well for development, including this example.

Added to the scaffolding are files which add authentication to the application.

License

The Unlicense

Deploy