Reputation: 4821
I'm using passport.js to provide OAuth authentication to my node.js app. But I do have one doubt:
When I receive the profile object when authenticating (when you define the OAuth strategy) is unique for all the providers or is specific for that provider?
passport.use(new FacebookStrategy({
clientID: conf.fb.appId,
clientSecret: conf.fb.appSecret,
callbackURL: "http://local.host:3000/auth/facebook/callback" }, function(accessToken, refreshToken, profile, done) {
var user = users[profile.id] ||
(users[profile.id] = { id: profile.id, name: profile.username });
done(null, user); } ));
Upvotes: 1
Views: 236
Reputation: 16000
It is specific to the provider. In this case, it will be the Facebook ID.
It is recommended that you create your own user record (in the database of your choice), and associate provider IDs with that record. Doing this also makes it easy to implement "connecting" accounts, so users can link other accounts (say Facebook and Twitter), and then login using either.
Upvotes: 1