0
votes

I trying to implement login facebook by using Loopback as API,

Following http://loopback.io/doc/en/lb3/Tutorial-third-party-login.html and https://github.com/strongloop/loopback-example-passport I can't apply the tutorial to my case because at the example, client side and server side are on the same project.

My app:

  1. Web application (NextJS custom express server)

    • example endpoint: www.myapp.com
    • User click login by facebook button to get access_token after that send to API.
  2. API application (Loopback)

    • example endpoint: www.api-myapp.com
    • API get access_token from client then fetch data from facebook graph API.
    • If email is existed then auto-login and return token to the client.
    • Else register a new user and return token to the client.

From the following flow, I can't implement this flow by using Loopback :( I can register/login via username and password in a normal case but I confusing to register/login by facebook login.

1

1 Answers

2
votes

This behavior would be very easy to implement using Loopback. Assuming you are following the third party login documentation, you would simply:

  • Enable facebook-passport authentication.
  • Create a button in your frontend for "login with facebook" which redirects the user to the authpath (ie http://<api-server>/auth/facebook).
  • Set the successRedirect to http://<app-server>/<post-login-url>.