एक node.js की परिचयात्मक book (एक express.js अनुप्रयोग का उपयोग प्रमाणीकरण गूगल OpenID द्वारा रणनीति) के अंतिम उदाहरण डेवलप करते समय, के बाद passport-google
पैकेज (जो 20 अप्रैल, 2015 को अप्रचलित हो गया है)passport-google-oauth2
पैकेज (Google OAuth 2.0 द्वारा प्रमाणीकरण रणनीति) और its documentation's page और example here पर संकेतों का पालन करने के बाद; मुझे oath2.js
मॉड्यूल द्वारा फेंक दिया गया था, जो मेरे Google+ खाते को चुनने के बाद नीचे दी गई त्रुटि मिली, userProfile(accessToken, done)
विधि के भीतर this._oauth2.get("https://www.googleapis.com/plus/v1/people/me",...)
को ठोस रूप से कॉल किया गया। संबंधित स्रोत कोड और मॉड्यूल निर्भरताएं नीचे दी गई हैं।Node.js "पासपोर्ट-google-OAuth2" उद्धार एक्सप्रेस आवेदन में त्रुटि "उपयोगकर्ता प्रोफ़ाइल को लाने में विफल"
समस्या की जड़ क्या हो सकती है?
ठोस त्रुटि है:
InternalOAuthError: failed to fetch user profile
at <...>\web-app\b4\node_modules\passport-google-oauth2\lib\oauth2.js:92:28
at passBackControl (<...>\web-app\b4\node_modules\passport-google-oauth2\node_modules\passport-oauth2\node_modules\oauth\lib\oauth2.js:124:9)
at IncomingMessage.<anonymous> (<...>\web-app\b4\node_modules\passport-google-oauth2\node_modules\passport-oauth2\node_modules\oauth\lib\oauth2.js:143:7)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
संबंधित आवेदन के कोड है:
passport = require('passport'),
//...
GoogleStrategy = require('passport-google-oauth2').Strategy; // #passport-google-oauth2
//...
/***** #passport-google-oauth2 vv *****/
passport.use(new GoogleStrategy({
clientID: "a_specific_value",
clientSecret: "another_specific_value",
callbackURL: "http://127.0.0.1:3000/auth/google/callback",
passReqToCallback:true
},
function(request, accessToken, refreshToken, profile, done) {
profile.identifier=profile.id;
return done(null, profile);
}
));
/***** #passport-google-oauth2 ^^ *****/
//...
/***** #passport-google-oauth2 vv *****/
app.get('/auth/google',
passport.authenticate('google', { successRedirect: '/',scope:
[ 'https://www.googleapis.com/auth/userinfo.email']})
);
app.get('/auth/google/callback',
passport.authenticate('google', {
successRedirect: '/',
failureRedirect: '/'
}));
/***** #passport-google-oauth2 ^^ *****/
एप्लिकेशन के पास निम्न निर्भरता है:
[email protected] ├─┬ [email protected] │ ├─┬ [email protected] │ │ └── [email protected] │ └── [email protected] ├─┬ [email protected] │ ├── [email protected] │ └── [email protected] ├─┬ [email protected] │ ├── [email protected] │ ├─┬ [email protected] │ │ └── [email protected] │ ├─┬ [email protected] │ │ ├── [email protected] │ │ ├── [email protected] │ │ ├── [email protected] │ │ ├── [email protected] │ │ └── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├─┬ [email protected] │ │ └── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ └─┬ [email protected] │ └── [email protected] ├─┬ [email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├─┬ [email protected] │ │ └── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├─┬ [email protected] │ │ ├── [email protected] │ │ └── [email protected] │ └── [email protected] ├─┬ [email protected] │ ├── [email protected] │ ├─┬ [email protected] │ │ └── [email protected] │ ├── [email protected] │ └─┬ [email protected] │ └── [email protected] ├─┬ [email protected] │ └── [email protected] ├─┬ [email protected] │ ├── [email protected] │ └── [email protected] ├─┬ [email protected] │ └─┬ [email protected] │ ├── [email protected] │ ├── [email protected] │ └── [email protected] ├── [email protected] ├── [email protected] └─┬ [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├─┬ [email protected] │ ├── [email protected] │ └─┬ [email protected] │ └── [email protected] ├─┬ [email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ └── [email protected] ├─┬ [email protected] │ ├── [email protected] │ ├── [email protected] │ └── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] └── [email protected]
वास्तव में है कि:
तुम भी
profile scope
प्राप्त कर सकते हैं:इसके बजाय, हम इस एक का उपयोग करना चाहिए यह मेरे लिए भी था, धन्यवाद! // www.googleapis.com/प्रमाणन/userinfo.profile' और 'https: // www.googleapis.com/प्रमाणन/userinfo.email'' profile' और 'ईमेल करने के लिए बदल – Nocturno
मैं भी पदावनत स्कोप' https था क्रमशः। – Samin
वाह धन्यवाद इस पर इतना समय बिताया। वे वास्तव में किसी तरह की त्रुटि वापस करना चाहिए! मेरे लिए कॉलबैक –