This app illustrates how to use Passport with Express to sign users in with Google. Use this example as a starting point for your own web applications.
To run this app, clone the repository and install dependencies:
$ git clone https://github.com/passport/todos-express-twitter-oauth2.git
$ cd todos-express-twitter-oauth2
$ npm install
This app requires OAuth 2.0 credentials from Google, which can be obtained by
setting up
a project in Google API console.
The redirect URI of the OAuth client should be set to 'http://localhost:3000/oauth2/redirect/twitter'
.
Once credentials have been obtained, create a .env
file and add the following
environment variables:
GOOGLE_CLIENT_ID=__INSERT_CLIENT_ID_HERE__
GOOGLE_CLIENT_SECRET=__INSERT_CLIENT_SECRET_HERE__
Start the server.
$ npm start
Navigate to http://localhost:3000
.
This example illustrates how to use Passport and the passport-twitter-oauth20
strategy within an Express application to sign users in with Google
via OAuth 2.0.
This app implements the features of a typical TodoMVC app, and adds sign in functionality. This app is a traditional web application, in which all application logic and data persistence is handled on the server.
User interaction is performed via HTML pages and forms, which are rendered via EJS templates and styled with vanilla CSS. Data is stored in and queried from a SQLite database.
After users sign in, a login session is established and maintained between the server and the browser with a cookie. As authenticated users interact with the app, creating and editing todo items, the login state is restored by authenticating the session.
Created by Jared Hanson