Adding OAuth Login to Mean.js

NOTE: This post requires that you have a web app set up through Facebook, Google, Twitter and/or Linkedin before continuing. To learn what OAuth is and/or how to set it up, check out my post entitled, “What is OAuth and How Does it Work?

Mean.js supports OAuth right out of the box, but it takes a bit of setting up.

The configuration files are found in /config/env/. The default file is ‘development.js’.  All that’s necessary to install basic OAuth for user authentication is to fill in the ‘ClientId’, ‘ClientSecret’ and ‘callbackUrl’ elements with their respective values.  Make sure your callback URL has been registered as allowed with your app!

Because all OAuth user data can be loaded using AngularJS directly into the user’s browser, if you don’t need to record data about your user you can just grab anything you want directly with Angular. Server-side OAuth should really be reserved for logging in and out.

If I’m wrong or missing something, comment and let me know!

Submit a Comment

Your email address will not be published. Required fields are marked *