Tag: passport google oauth

缺less必要的参数:redirect_uri与passport-google-oauth

在我的MEAN Stack应用程序中使用passport-google-oauth: "0.2.0" (在这里find: https : //github.com/jaredhanson/passport-google-oauth )。 当我运行应用程序并尝试使用Google APIlogin时,将返回此错误 这是一个错误。 错误:invalid_request 缺less所需的参数:redirect_uri 请求详细信息scope = https://www.googleapis.com/auth/plus.login response_type = code redirect_uri = client_id = xxxx-xxxx.apps.googleusercontent.com redirect参数在这里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(新的GoogleStrategy({ 客户ID:GOOGLE_CLIENT_ID, clientSecret:GOOGLE_CLIENT_SECRET, callbackUrl:“ http://127.0.0.1:3000/auth/google/oauth2callback ”},函数(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:'/ […]

使用google-passport-oauthlogin后,req.user未定义

在使用Google帐户成功login后,在callback请求中,将req.user设置为正确的用户,并且req.isAuthenticated()为true。 大! 但是,任何后续请求都会将req.user定义为undefined。 不pipe我做什么。 这个问题同时出现在passport-google-auth2和passport-google-auth中 。 这是我的index.js样子: app.set('views', './src/express/views'); app.set('view engine', 'jsx'); app.engine('jsx', expressReactViews.createEngine({ beautify: true })); app.use(express.static('./dist')); app.use(cookieParser()); app.use(bodyParser.json()); app.use( bodyParser.urlencoded({ extended: true })); app.use(session({ secret: 'keyboard cat', proxy: true, resave: true, saveUninitialized: true, cookie: { secure: true } })); app.use(passport.initialize()); app.use(passport.session()); passport.serializeUser(function(user, done) { // user is passed here correctly done(null, user.id); }); […]

redirect_uri的参数值无效:Missing scheme:/ auth / google_auth_code / callback

编辑 : 这是一个最小的可行的项目 我正尝试从服务器端stream的授权代码获取来自Google的访问和刷新令牌。 我遵循Google的指南: https : //developers.google.com/identity/sign-in/web/server-side-flow 。 我正在使用护照和护照-Google-authcode 。 以下是节点应用的路由: router.get('/auth/google_auth_code', passport.authenticate('google_authcode', { scope: [ 'https://www.googleapis.com/auth/calendar', 'profile', 'https://www.googleapis.com/auth/userinfo.email' ] }), function () { res.end(); }) router.get('/auth/google_auth_code/callback', passport.authenticate('google_authcode', { failureRedirect: '/error' }), function (req, res) { // do something with req.user res.send('hello'); } ); 这是该策略的护照configuration。 passport.use('google_authcode', new GoogleAuthCodeStrategy({ clientID: 'my client id', clientSecret: 'my […]