Implementing OAuth On FeathersJs

Omoike Sarah Igho
2 min readNov 8, 2017
User authentication

Holla! So I have been wondering how authentication is done or simply, how the process works. After implementing this in my application, I resolved to writing. Yes, of course I mentioned I was going to write about implementing Basic authentication in your feathersJs application.

Remember when you initially signed-up for medium, you had the option of signing up using your google account, that’s an authentication process but using Google as a provider. You could also use facebook, github, and local authentication(user has to input username and password).

OAuth implentation in feathersJs:

With the new feathersJs authentication plugins built on top of passportJS, there’s flexibility, hence you can authenticate the feathers client. Using feathers-cli you can easily setup a new application with 0Auth by following these steps:

STEP 1: Start by installing feathers-cli, which allows you to easily setup a new application with OAuth.

npm install -g feather -cli oryarn global feather -cli

STEP 2: create a folder/dir (with a name of your choice):

mkdir feathers_OAuth 

STEP 3: Enter into your root directory.

cd feathers_0Auth

STEP 4: Inside your base folder, run: (Please select default Prompts).

feathers generate app

STEP 5: run

feathers generate authentication

In step 5, you will be prompted to choose authentication provider(s). Although, other passportJS strategies that are not in the list can be manually configured. You will also be prompted to choose the kind of service(database), I chose MongoDB. It will automatically create the database connection string.

SETTING UP THE OAuth PROVIDER:

When the app setup is done the OAuth provider generates a ‘Client ID’ and ‘Client Secret’. You can find the configuration in the project config/ folder.

As seen here my Oauth service provider is github and google

CONFIGURING YOUR APPLICATION

To configure your application, input the application ‘client ID’ and ‘client service’ so that it can communicate with the chosen provider, using google? check this link out.

The generator added a key to the config for the selected provider. Copy over and replace the placeholders with the ‘Client ID’ and ‘Client Services’.

Voila! your app is ready for Auth logins. You can test the login with OAuth,

how this works is it redirects users to the authentication provider using your “Client ID” and “Client Secret”.

Stay Awesome :).

--

--