An Angular application I wrote to experiment with Twitter authentication, Twitter API, and Heroku deployment.
The app has a landing page where the user can sign-in using his twitter-account credentials. Once logged-in the user is redirected to a page that shows a list of 10 twitter subjects which are currently the most popular worldwide. The right panel has a list of twits for the selected subject.
- Angular
- Bootstrap
- Node with Express 4.
- Passport with TwitterStrategy for authentication.
- Twitter API
- Heroku
https://ritmo-allegro.herokuapp.com
Make sure you complete these steps before running the application
#####(1) Create a Twitter application In order to use Twitter authentication, you must first create an application at Twitter Developers. When created, an application is assigned a consumer key and consumer secret. Your application must also implement a callback URL, to which Twitter will redirect users after they have approved access for your application.
- If you run the app locally, set the callback to "http://127.0.0.1:5000/auth/twitter/callback".
- If you run the app on heroku, set the callback to "https://the-app-name.herokuapp.com/auth/twitter/callback". Where
the-app-nameis the name of your heroku app
#####(2) Set environment variables Create the following environment variables and set them equal to consumer_key, consumer_secret, and callback_url of the Twitter application you just created in step (1). Also set your cookie and session secrets.
- TWITTER_CONSUMER_KEY
- TWITTER_CONSUMER_SECRET
- TWITTER_CALLBACK_URL
- COOKIE_SECRET,
- SESSION_SECRET,
Make sure you have Node.js installed.
$ npm install
$ bower install
$ grunt dist
$ node dist/server.jsThe app should now be running on localhost:5000.
Make sure you have the Heroku Toolbelt installed.
$ cd dist/
$ heroku create the-app-name
$ git push heroku master
$ heroku open
The app should now be running on https://the-app-name.herokuapp.com
For more information about using Twitter auth and api.
For more information about using Node.js on Heroku, see these Dev Center articles: