node.jspassport.jsfeathersjsfeathers-authenticationpassport-facebook-token

User signup feathers-authentication with passport-facebook-token


I am trying to allow users to sign up for my service via "login with facebook".

Mobile app user signup via facebook login

I have already done arrow 1-2. I need to do arrows 3-6. I have made a minimal Feathersjs example at https://github.com/morenoh149/feathers-chat-facebook-signup-api

I seem to be having trouble getting feathers-authentication and passport-facebook-token to generate the User object and sign them up. I've reviewed passport-facebook-token carefully. This answer explains that in the callback to passport-facebook-token you should create the User object. How do I do this with feathers-authentication?

When I provide the token in the body

curl localhost:3030/authentication \
  --data-binary '{\
    "strategy": "facebook-token", \
    "access_token": "<phone token>" \
  }'

I get

{"name":"NotAuthenticated",
"message":"You should provide access_token","code":401,
"className":"not-authenticated",
"data":{"message":"You should provide access_token"}

when I pass the token as a header

curl localhost:3030/authentication \
  -X POST \
  -H "Authorization: Bearer <access token>"

I get error

{"name":"GeneralError",
"message":"Cannot read property 'toLowerCase' of undefined",
"code":500,"className":"general-error","data":{},"errors":{}}

Solution

  • So I downloaded and ran the repo, I used VSCode to run the app and set break points. I created a breakpoint in the before create hooks on users.

    The issue here is that the gravatar hook is expected the email to be context.data but it is in fact embedded within the facebook response. You will need to look at extracting the email from that data so that you can create a gravatar or just remove the gravatar hook altogether.