Register Oauth

Register your application (or in this case a dummy application) with all of the OAuth providers you want to use, except Google - as Google uses OpenID. Each Oauth provider handles authentication differently and has names for their authentication keys, so make sure to read the documentation before setting up an application.

In all cases use the following url for the call - “http://localhost:1337/auth/[oauth_provider_name]/callback”. Also, be sure to take note of the generated authentication keys.

Facebook

Twitter

Github

Setup an authentication file

Create a separate file in the root directory called “oauth.js” and add the following code:

Update the /account route:

Test Redux

Fire up the server and make sure Facebook authentication is still working. Once logged in, open a mongo shell and ensure there is a new user in the database. Log in and log out several times with Facebook. Check the mongo shell again. There should still only be one user.