Skip to content

A simple Express app which integrates OAuth authentication with Google, Github and Facebook.

License

Notifications You must be signed in to change notification settings

vladpirlog/express-oauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express OAuth 2.0

A simple Express app which integrates OAuth authentication with Google, Github and Facebook.

App Screenshot

Getting Started

First, the client IDs given by the OAuth providers must be hardcoded into the public/javascripts/utils.js file, because the requests made from the browser must include these IDs as a query parameter. On the other hand, the client secrets must only be included as environment variables.

Clone and cd into this repository

git clone https://github.com/vladpirlog/express-oauth.git
cd express-oauth

Install the dependencies

npm install

Run the app

npm start

An instance of the app will run be running at http://localhost:3000/.

Environment variables

A set of environment variables must be provided in a .env file placed in the project's root folder.

  • PORT - port to run the application on; defaults to 3000
  • NODE_ENV - NodeJS environment; defaults to development
  • JWT_KEY - key for symmetrically encrypting the JWTs
  • GOOGLE_CLIENT_ID - the OAuth client ID provided by Google
  • GOOGLE_CLIENT_SECRET - the OAuth client secret provided by Google
  • GITHUB_CLIENT_ID - the OAuth client ID provided by GitHub
  • GITHUB_CLIENT_SECRET - the OAuth client secret provided by GitHub
  • FACEBOOK_CLIENT_ID - the OAuth client ID provided by Facebook
  • FACEBOOK_CLIENT_SECRET - the OAuth client secret provided by Facebook

Using the app

The user will be prompted to select one of the 3 ways of authentication. Upon giving permission to access basic account info, the user's email and profile image will be displayed on the homepage. These will be stored for a year as an encrypted JWT in a cookie.

Feel free to revoke the access of the OAuth app in the Google/Github/Facebook account dashboard whenever you want.

The user's email and profile picture URL will not be stored anywhere else other than the express_oauth cookie.

Getting the OAuth credentials

The client IDs and client secrets can be claimed from the following sources:

Contributions

Feel free to contribute to the project by improving the code structure and integrating new OAuth providers.

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A simple Express app which integrates OAuth authentication with Google, Github and Facebook.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published