OAuth login over DDP

Hello everyone.

We have two meteor apps running, one for backend and one for frontend. Basically, I’m trying to connect these two apps over DDP. Everything works correctly, except OAuth Facebook login.
I’ve changed Accounts.connection to the appropriate value and I’ve created both Meteor.users and Accounts.users accordingly.
Meteor.loginWithPassword() method works as expected, but Meteor.loginWithFacebook() method fails with the following error:
> errorClass {message: "No matching login attempt found", errorType: "Accounts.LoginCancelledError"}

I’ve tried numerous ‘solutions’ I’ve found browsing the forums, but nothing seems to work. I’ve tried accounts-facebook-ddp smart package as well, but I had not luck. I even tried changing ROOT_URL to the DDP server address but nothing happens, nothing changes.

So, my question is, does anybody have experience with this issue, and more importantly, does anybody have a possible solution?

Hi, Im currently facing the exact same issue as you, did you ever found a solution? if you did please could you direct me in some direction.

The thing is with OAuth that the login service (facebook in that example) will redirect back to your app (https://your-app.com/_oauth/facebook with corresponding oauth parameters). This will be always handled from your frontend server. If you would change that redirect url to your backend server, then the login would fail since you started the login process on a different host.

So if you want to use the existing plugin there is no way to properly tackle this. At least I didn’t find a solution (having the same setup). What works is when you connect your frontend app to the same database as the backend. This is the setup I am currently running with and it’s working fine (although I don’t really like it).

If that’s not an option for you you need to implement OAuth handling by yourself. You would need to intercept the http call (/_oauth/facebook) and make a call to your backend server to complete the process.

1 Like