मैं नोड जेएस के पासपोर्ट मॉड्यूल का उपयोग करके Google बटन के साथ साइन इन करने का प्रयास कर रहा हूं। मैं व्यक्तियों को ईमेल आईडी, नाम, प्रोफ़ाइल तस्वीर प्राप्त करने की कोशिश कर रहा हूं। मैं स्थानीय सर्वर पर तस्वीर डाउनलोड करने की कोशिश कर रहा हूं। Google दायरे में 'ईमेल' जोड़ने के बाद भी ईमेल आईडी वापस नहीं कर रहा है और न ही प्रोफ़ाइल तस्वीर के लिए लौटा लिंक काम कर रहा है। मैंने इस प्रश्न के विभिन्न उत्तरों को देखा है लेकिन सभी कहते हैं कि userinfo.email .it को अब हटा दिया गया है। गूगल प्रलेखन के अनुसार नया स्कोप पैरामीटर ईमेल है नीचे मेरी कोड किसी भी मदद की सराहना की पासपोर्टGoogle oauth ईमेल पासपोर्ट प्रमाणीकरण वापस नहीं कर रहा है
passport.use(new GoogleStrategy({
clientID : configAuth.googleAuth.clientID,
clientSecret : configAuth.googleAuth.clientSecret,
callbackURL : configAuth.googleAuth.callbackURL,
},
function(token, refreshToken, profile, done) {
// make the code asynchronous
// User.findOne won't fire until we have all our data back from Google
process.nextTick(function() {
// try to find the user based on their google id
User.findOne({ 'google.id' : profile.id }, function(err, user) {
if (err)
return done(err);
if (user) {
// if a user is found, log them in
return done(null, user);
} else {
// if the user isnt in our database, create a new user
var newUser = new User();
console.log(profile);
//JSON.parse(profile);
// set all of the relevant information
newUser.google.id = profile.id;
newUser.google.token = profile.token;
newUser.google.name = profile.displayName;
newUser.google.uname = profile.emails[0].value; // pull the first email
newUser.google.dp = profile._json.picture;
console.log('url is');
console.log(newUser.google.name);
console.log(newUser.google.dp);
//console.log(profile.picture);
Download(newUser.google.uname, newUser.google.dp,function(err){
if(err)
console.log('error in dp');
else
console.log('Profile Picture downloaded');
});
// save the user
newUser.save(function(err) {
if (err)
throw err;
return done(null, newUser);
});
}
});
});
}));
};
routes.js
app.get('/connect/google', passport.authorize('google', { scope : ['profile', 'email'] }));
// the callback after google has authorized the user
app.get('/connect/google/callback',
passport.authorize('google', {
successRedirect : '/profile',
failureRedirect : '/'
}));
download.js
module.exports = function(username, uri, callback){
var destination;
request(uri).pipe(fs.createWriteStream("./downloads/"+username+".png"))
.on('close', function(){
console.log("saving process is done!");
});
धन्यवाद। मैं काम कर रहा हूँ :) क्या आप कृपया मुझे fb oauth में भी मदद कर सकते हैं। मुझे यह काम मिल गया है लेकिन टोकननाइजेशन त्रुटि हो रही है। लिंक http://stackoverflow.com/questions/38299165/how-to-use-random-guid-with-passport-module-and-express-server –
क्या आपको उपयोगकर्ता प्रोफ़ाइल तक पहुंचने का प्रयास करने पर हर बार प्राधिकरण स्क्रीन प्राप्त होती है ? –
सच यह है कि मैं इसके साथ शुरू कर रहा हूं। मुझे और परीक्षण करना है, लेकिन अभी के लिए यह समस्या नहीं है। फेसबुक के साथ लॉगिन मैंने लागू नहीं किया है। जब मैं इस पर काम करता हूं, अगर मैं कर सकता हूं, तो मैं आपके प्रश्न के साथ आपकी मदद करने की कोशिश करूंगा। – pariasdev