Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'split' of undefined in Profile.js with GSuite login #105

Closed
mbalex99 opened this issue Dec 7, 2019 · 5 comments · Fixed by #109
Closed

Cannot read property 'split' of undefined in Profile.js with GSuite login #105

mbalex99 opened this issue Dec 7, 2019 · 5 comments · Fixed by #109
Assignees
Labels
Milestone

Comments

@mbalex99
Copy link

mbalex99 commented Dec 7, 2019

Description

When using 1.3.1 I am getting an error when a successful login occurs with a GSuite Login.

TypeError: Cannot read property 'split' of undefined
    at new Profile (\node_modules\passport-auth0\lib\Profile.js:9:29)

Reproduction

passport.use(
  new Auth0Strategy(
    {
      domain: process.env.AUTH0_DOMAIN,
      clientID:
        process.env.AUTH0_CLIENT_ID,
      clientSecret: process.env.AUTH0_CLIENT_SECRET,
      callbackURL:
        process.env.AUTH0_CALLBACK_URL
    },
    function(_accessToken, _refreshToken, extraParams, profile, done) {
      console.log(profile)
      done(null, profile)
    }
  )
);

My routes are as follows:

  server.get(
    "/auth0",
    passport.authenticate("auth0")
  );
  server.get(
    "/auth0/callback",
    passport.authenticate("auth0", { successRedirect: '/posts', failureRedirect: "/login" })
  );
  server.get('/login', (req, res) => {
    app.render(req, res, '/login')
  })
  server.get('/logout', (req, res) => {
    req.logOut();
    res.redirect('/login');
  })

I see that the authentication is successful, just that this library is getting empty data. If I add console.log in Profile.js

function Profile(data, raw) {
  console.log(`data `, data)
  console.log(`raw `, raw)
  // omitted code 
}

It will print:

data  {}
raw  {}

Environment

Please provide the following:

  • Version of this library used: 1.3.1
  • Version of the platform or framework used, if applicable: Node 12.1.0
@mbalex99
Copy link
Author

mbalex99 commented Dec 7, 2019

Actually I fixed it I needed to add the scope:

Originally I had:

server.get(
    "/auth0",
    passport.authenticate("auth0", {scope: ["email"]})
  );

Now I have:

server.get(
    "/auth0",
    passport.authenticate("auth0", {scope: ["openid profile"]})
  );

Now data flows through and the parsing does not throw an error.

@joshcanhelp
Copy link
Contributor

@mbalex99 - Thank you for the report here. That's definitely related to the latest release (PR #103). Is this in an existing application that was working before or a new one?

@joshcanhelp joshcanhelp self-assigned this Dec 7, 2019
@mbalex99
Copy link
Author

mbalex99 commented Dec 7, 2019

This was a new application. I am not sure if it would have worked with an older version of this library.

@cbovis
Copy link

cbovis commented Dec 17, 2019

I'm seeing this issue as well since upgrading from 1.3.0 to 1.3.1. I'll gather some more info about my specific usage and report back.

@joshcanhelp
Copy link
Contributor

Appreciate the information here everyone and apologies for the breakage on a patch release.

Not having an ID of some kind is a problem and it looks like not including the openid scope is leading to that ID being missing. I can't get any meaningful user identity response if I don't include that scope so I'd be curious how an existing app is configured where this is a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants