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 get github auth working #135

Closed
jbatx opened this issue Apr 28, 2020 · 4 comments
Closed

Cannot get github auth working #135

jbatx opened this issue Apr 28, 2020 · 4 comments

Comments

@jbatx
Copy link

jbatx commented Apr 28, 2020

I carefully followed the getting started guide all the way through - stopping at the writing tests section. I'm hung up on getting github auth to work. I've added the oath app to GH and update the authentications section of default.json. Logging into GH is working and I get the permissions grant screen. Preceding past the that, based on the guide, I expected to be logged into the chat app after authenticating to github.

However, I keep getting redirected to the chat login page. The error that occurs immediately after the permission grant is: Cannot read property 'toLowerCase of null

Here's a screenshot of this after the github permissions grant: https://www.evernote.com/l/ADqsa_P7jj1Ly5YVahH5b4LMbDKTgBX3CEU

Here's the error and stack trace I get on all consecutive attempts to login with githib:
https://www.evernote.com/l/ADq81BrDFOxHx4lLuGKQwt88X_VkvzZYr7k

Here are the auth parts from default.json
"authentication": {
"oauth": {
"redirect": "/",
"github": {
"key": "hidden",
"secret": "hidden"
}
},
"entity": "user",
"service": "users",
"secret": "wplCi9j8gbUzXjBCoP3NGJzGUN8=",
"authStrategies": [
"jwt",
"local"
],

Is there something missing from the quick-start? Perhaps another config setting to enable github?

System configuration

Mac
chrome 81.0.4044.92
node 8.12
"dependencies": {
"@feathersjs/authentication": "^4.5.3",
"@feathersjs/authentication-local": "^4.5.3",
"@feathersjs/authentication-oauth": "^4.5.3",
"@feathersjs/configuration": "^4.5.3",
"@feathersjs/errors": "^4.5.3",
"@feathersjs/express": "^4.5.3",
"@feathersjs/feathers": "^4.5.3",
"@feathersjs/socketio": "^4.5.3",
"@feathersjs/transport-commons": "^4.5.3",
"compression": "^1.7.4",
"cors": "^2.8.5",
"feathers-nedb": "^5.1.0",
"helmet": "^3.22.0",
"nedb": "^1.8.0",
"serve-favicon": "^2.5.0",
"winston": "^3.2.1"
},

@daffl
Copy link
Member

daffl commented Apr 28, 2020

This error usually happens when

  • You did not update src/authentication.* file with the GitHub strategy according to the guide?
  • The profile does not have an email address

@jbatx
Copy link
Author

jbatx commented Apr 28, 2020

@daffl thank you for the fast reply! It turns out that GH auth is actually working. As you pointed out, the issue is that my GH profile is not providing my email in the response. I have my email set to private - perhaps that's why. The error is coming from the call to email.toLowerCase() in users.class.js.

@daffl
Copy link
Member

daffl commented Apr 28, 2020

In that case the code from customizing the service has to be adjusted to work with the data you are getting. Simplest would be to only use the githubId or customizing the data you want from the profile:

exports.Users = class Users extends Service {
  create (data, params) {
    // This is the information we want from the user signup data
    const { githubId } = data;

    // The complete user
    const userData = {
      githubId
    };

    // Call the original `create` method with existing `params` and new data
    return super.create(userData, params);
  }  
};

@jbatx
Copy link
Author

jbatx commented Apr 28, 2020

thanks! That's what I was about to do. I first confirmed that the private email was, in fact, the issue.

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

No branches or pull requests

2 participants