node.jssails.jswaterlock

waterlock fb auth - registering with authcode


I have an ember-cli app that authenticates against fb using ember-simple-auth and torii. When the process is finished I end up with an authcode.

I also have an API built with Node / Sails / Waterlock

I thought I would be able to use Waterlock facebook auth to push this code to

http://my-node-app.com:1337/auth/facebook_oauth2?code={{some-code}}

which would then allow it to do the handshake with FB, fetch my profile info, create my user and log me in.

This works I think if I have already registered though the API, and it does log me in on the API except that there is no user data, no fb id nothing.

The response from calling the URL above with a valid code is:

{
  auth: {
    facebookId: null,
    name: null,
    createdAt: "2015-01-10T15:05:44.417Z",
    updatedAt: "2015-01-10T15:05:44.459Z",
    id: 10,
    user: 10
  },
  createdAt: "2015-01-10T15:05:44.447Z",
  updatedAt: "2015-01-10T15:05:44.447Z",
  id: 10
}

And here is the result of /users

{
  users: [
  {
    attempts: [
      12
    ],
    jsonWebTokens: [ ],
    auth: 10,
    createdAt: "2015-01-10T15:05:44.447Z",
    updatedAt: "2015-01-10T15:05:44.447Z",
    id: 10
  }
]
}

Should I be able to do this? Or do I need to explicitly register users on the api/auth/login?type=facebook url?

[UPDATE]

Looking at the code here https://github.com/waterlock/waterlock-facebook-auth/blob/master/lib/controllers/actions/oauth2.js it looks like I am correct...

The 1st call in the action is:

fb.confirmIdentity(req.query.code, accessTokenResponse);

Inside accessTokenResponse it calls into fb.getMe(userInfoResponse); where in userInfoResponse it calls into the main waterlock framework engine.js to store the user...

So from my digging this should work... I have no idea where it is falling down.


Solution

  • This was working as expected it's just waterlock wasn't returning the fb error passed to it (). I created a pull request so it's easier to debug these sorts of issues.

    https://github.com/waterlock/waterlock-facebook-auth/pull/3