Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialglenn romaniuk
32,520 Pointsnode.js passport oauth error "Cannot read property '0' of undefined"
Downloaded the sourcecode for the github authentication. When run i recieve the "Cannot read property '0' of undefined" error. Any ideas?
3 Answers
Lilly Piri
Full Stack JavaScript Techdegree Graduate 19,468 PointsI had to add scope and it fixed this error.
passport.use(
new GitHubStrategy(
{
clientID: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
callbackURL: 'http://localhost:3000/auth/github/return',
scope: 'user:email'
}, generateOrFindUser
)
);
Khanh Tran
Full Stack JavaScript Techdegree Student 944 PointsHi,
To solve the problem, go to your GitHub settings page > Profile. And change your "Public email" field from "Don't show my email address" to your email. Save it! That's all :D
Michael Liendo
15,326 Pointsstooooop
Michael Liendo
15,326 PointsHard to tell without looking at your code. I didn't have any trouble when I cloned the repo. Just getting the basics out of the way: You ran npm install?
Where are you getting the error?
Valeshan Naidoo
27,008 PointsValeshan Naidoo
27,008 PointsThat fixed it for me, other issues I had was the saveUninitialized spelling, and users instead of user for user._id. Long coding sessions like these always leave me rife with silly errors.