question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with connect 3.3.5 (Missing required parameter: scope)

See original GitHub issue

I had a working app with passport-google-oauth v0.1.5 and passport v0.1.16 on node v0.8 with connect v2.27.1. The issue appeared since I updated to connect v3.3.5 on node v0.10.38 and passport-google-oauth v0.2.0 and passport v0.2.1.

The first request looks OK to me.

https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force&user_id=testaccount%40gmail.com&response_type=code&redirect_uri=http%3A%2F%2Fapp.testapp.com%3A5000%2Foauth2%2Fcallback&scope=profile%20email&client_id=XXXXXXXX.apps.googleusercontent.com

After click the Accept button at the permission page I see this problem.

400. That’s an error.
Error: invalid_request
Missing required parameter: scope
Request Details
response_type=code
redirect_uri=http://app.testapp.com:5000/oauth2/callback
client_id=XXXXXXXX.apps.googleusercontent.com
That’s all we know.

Here are the details, how I set up.

passport.use new GoogleStrategy(
  clientID: process.env.GOOGLE_CLIENT_ID || conf.GOOGLE_CLIENT_ID
  clientSecret: process.env.GOOGLE_CLIENT_SECRET || conf.GOOGLE_CLIENT_SECRET
  callbackURL: "https://" + process.env.HOST) + "/oauth2/callback"
  passReqToCallback: true
, (req, accessToken, refreshToken, profile, done) ->
server = connect()
  .use(cookieParser())
  .use(bodyParser.json())
  .use(bodyParser.urlencoded({extended: true}))
  .use(session(
    store: new RedisStore(
       pass: getRedisParams().pass
       host: getRedisParams().host
       port: getRedisParams().port
       ttl: 3600 #one hour
     )
    secret: "XXXXXXXX"
     saveUninitialized: true
     resave: true
     cookie:
       domain: process.env.HOST || conf.HOST
       maxAge: 604800000
  ))
  .use(passport.initialize())
  .use(passport.session())
  .use(connectRoute(routes))
(passport.authenticate('google',
    scope: [
      'profile'
      'email'
    ]
    accessType: 'offline'
    userID: email
    approvalPrompt: 'force'
  )) req, res, next
    (passport.authenticate('google',
      failureRedirect: '/oauth2/failed'
      successRedirect: '/oauth2/success'
    )) req, res, next

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Ekzercommented, May 22, 2017

For anyone who gets the scope problem, pass it to Passport params like this: (it works perfect for me)

` new GoogleStrategy({ clientID: global.config.passport.google.clientID,

        clientSecret: global.config.passport.google.clientSecret,

        callbackURL:  "http://localhost:3000/login/google/callback",//global.config.host+global.config.passport.google.callbackUrl,

        usernameField : "email",

        passwordField : "password",

        scope: "https://www.googleapis.com/auth/plus.login",

        passReqToCallback : true // allows us to pass back the entire request to the callback
        },

        function (req, token, refreshToken, profile, done) {

            token;

        })`
0reactions
ki9uscommented, Apr 20, 2017

Just in case this helps anyone coming from google, I was having this error when doing:

app.get('/login/google/callback', (req,res) => {
  passport.authenticate( 'google', {failureFlash:true} );
  // Callback
});

I guess the call to passport.authenticate() has to be directly in the express route’s callback chain:

app.get('/login/google/callback', 
  passport.authenticate( 'google', {failureFlash:true} ),
  (req,res) => {
    // Callback
  }
);

That’s working for me now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error 400: invalid_request Missing required parameter: scope
Hello! Well, seems that, during the HTTP requests and redirects, for some reason, the HTTP request that should contain the scope GET parameter...
Read more >
Missing required parameter: scope | Error Resolved - YouTube
Missing required parameter : scope | Error Resolved |Google Oauth. Watch later. Share. Copy link. Info. Shopping. Tap to unmute.
Read more >
Missing required parameter: scope when using ...
I'm successfully generating $authorizationUrl using the code below. However on using that URL I'm receiving the error: Missing required parameter: scope.
Read more >
RFC 4960: Stream Control Transmission Protocol
Recommended Transmission Control Block (TCB) Parameters ......129 13.1. ... but the SCTP association is a broader concept than the TCP connection.
Read more >
Creating and Configuring an Oracle Database
You must use the advanced configuration mode of DBCA or the CREATE DATABASE statement to select a non-recommended character set. If no character...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found