OAuth Login (Passport.js) Tutorial by The Net Ninja is a good free youtube tutorial on using Passport authentication with Express and Mongo/Mongoose with mLab.
For People with an Attention Span Longer Than a Tsetse Fly
I wanted to understand Passport better (rather than just cutting and pasting) so I found this free tutorial on youtube by the Net Ninja. It did a good job.
He slowly built an Express/Mongoose app from scratch, implementing Passport authentication with Google. Rather than using mongo locally, he shows how to create an mLab account and accesses that. (This might be a good idea because then you don’t have to worry about a user having mongo properly installed on their system and knowing how to view the data locally.)
He does use ejs as a templating engine, but doesn’t use any features beyond basic HTML until the last few videos where he does a few simple ejs things and then explains very clearly what is happening. If you haven’t used ejs before, it won’t be a problem.
The tutorial assumes a basic knowledge of Node and npm but pretty much explains everything else as he goes.
- Very methodical, explaining each step as he goes. Didn’t skip over explaining things the way many tutorials do. He doesn’t assume you know something and gloss over it.
- Explained well what was happening behind the scenes.
- Unlike a lot of tutorials, didn’t get too sidetracked with his own idiomatic approach. Didn’t get distracted with unimportant (to the topic and technologies) features.
- Videos are broken into easy to digest 5-10 minute segments (21 in all).
- He tests as he goes, making it easier to see what is happening and find mistakes.
- His perky and affable demeanor keeps it fun.
- He talks kind of fast, but he is often repeating things for clarity so this isn’t as bad as it seems. If someone is brand new to Express, etc, they will need to pause in a few sections and backup. But this is made easier to handle because the videos aren’t too long and he frequently stops to test.
- There are a few slight stylistic qualms I might have. For example, I wouldn’t put the CSS directly into the ejs file, but probably he did that just for simplicity, trying to keep the tutorial focused on the subject (a good thing). Also, he stored his keys in a specific keys file that gets put in the .gitignore - this works, but I think the dotenv approach is more common. But it does the job and is secure (as long as anyone else working on the code remembers to always keep that file secret.) But these are really nitpicky points.
All in all I enjoyed the tutorial - it cleared up a lot of things for me. I would recommend it for anyone starting the backend dynamic web app projects - I sooo wish I had seen this when I’d started those projects. Any intermediate coder who is still not clear what is going on with passport could also benefit.
I look forward to trying some other of his videos.