在我MEAN堆棧的應用程序使用passport-google-oauth: "0.2.0"
REDIRECT_URI(這裏找到:https://github.com/jaredhanson/passport-google-oauth)。當我運行應用程序,並嘗試用谷歌API返回此錯誤缺少必需的參數:與護照谷歌-的OAuth
- That’s an error.
Error: invalid_request
Missing required parameter: redirect_uri
Request Details scope= https://www.googleapis.com/auth/plus.login response_type=code redirect_uri= client_id=xxxx-xxxx.apps.googleusercontent.com
重定向PARAM登錄是這裏 passport-init.js
var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
var GOOGLE_CLIENT_ID = "xxx-xxx.apps.googleusercontent.com"; var GOOGLE_CLIENT_SECRET = "xxxx";
passport.use(new GoogleStrategy({
clientID: GOOGLE_CLIENT_ID,
clientSecret: GOOGLE_CLIENT_SECRET,
callbackUrl: " http://127.0.0.1:3000/auth/google/oauth2callback " }, function(accessToken, refreshToken, profile, done){ done(null,profile); }));
的路線在這裏authenticate.js
router.get('/google', passport.authenticate('google', { scope: [' https://www.googleapis.com/auth/plus.login ']}), function (req, res){ });
router.get('/google/oauth2callback', passport.authenticate('google', { successRedirect: '/auth/success', failureRedirect: '/auth/failure' }) , function (req, res) {res.redirect('/');});
我相信我缺少一些簡單的東西,但我不知道在這個問題中要添加什麼,它會給你最好的inf ormation。請問,我會盡力回答你。這就是相關數據的感覺。
有趣的是,如果我加入callbackUrl手動然後一切都很正常。我可以達到Google API的罰款。然後,我可以選擇「允許」或「拒絕」請求。
我要放棄這一做法,並嘗試https://github.com/google/google-api-nodejs-client/代替。 – Trewaters