اذهب إلى المحتوى

السؤال

نشر (معدل)

أستخدم في المشروع  node.js , passport-google-oauth2 ، و أحاول إضافة إمكانية تسجيل الدخول بواسطة جوجل.

بعد ظهور اختيار الحساب و الضغط عليه، يعاد توجيه الصفحة بنجاح كما هو مطلوب لكن الصفحة لا تفتح و لا يحدث تسجيل دخول و يظهر الخطأ التالي: 

[nodemon] app crashed - waiting for file changes before starting...

passport.js:


passport.use(new GoogleStrategy({
    clientID: process.env.GOOGLE_CLIENT_ID,
    clientSecret: process.env.GOOGLE_CLIENT_SECRET,
    callbackURL: "http://localhost:4000/auth/google/callback",
    passReqToCallback: true
},
    function (request, accessToken, refreshToken, profile, done) {

        done(null, profile);
    }
));

:index.js

router.get('/auth/google',
  passport.authenticate('google', {
    scope: ['email', 'profile']
  }
  ));

router.get('/auth/google/callback',
  passport.authenticate('google', { failureRedirect: 'signup' }),
  (req, res) => {
    res.redirect('/')
  });

 

تم التعديل في بواسطة Hadi255

Recommended Posts

  • 0
  • 0
نشر

أضفت اليوم تعديلا آخر وهو جعل : session: false  كما يلي :

:index.js

router.get('/auth/google',
  passport.authenticate('google', {
    scope: ['email', 'profile']
  }
  ));

router.get('/auth/google/callback',
  passport.authenticate('google', {
    session: false,
    failureRedirect: 'signup'
  }),
  (req, res) => {
    res.redirect('/users/profile')
  });

النتيجة أن الصفحة فتحت في المكان المطلوب بنجاح لكن بدون تسجيل الدخول ، وكأنني لم أفعل شيئاً. 

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...