Facebook Login Button

Hello everyone,

i recently started working on a project that it required a Facebook login button.
I have successfully set up the button apart from the part where I must redirect the user to my dashboard area which must only be accessible to registered users.

From my understanding I need to fill this field here in the developers facebook settings page

which will redirect the user to my dashboard. I am guessing that the redirection link must include a token which that will login the user automatically in my dashboard. Am I right so far?

My concern is if that link can be accessed by anyone and if someone get their hands on it can use it to login to my app without registering.

Also, is there any up to date tutorials describing the whole process with setting up the button and redirecting the user to somewhere?

thank you very much

I finished my social login/signup validations a few days ago.
I set the Valid OAuth Redirect URIs on my Facebook dashboard to the same page where I called the authority.
So I redirect the user back to the same page. I fetch the data from the response and this data I send to the server…
If you have multipage project, then you can redirect the user to the server side too, eg. where you send the manual login data anyway. It is not worked me because I try to use social login on a single page app.

1 Like

Hey Lendoo,

So basically you are saying that I do not need the Valid OAuth Redirect URIs to login the user but I can do it manually through the code?

You can do it on server side or on client side too. It is up to you.
On “Client OAuth Settings” page you find a “Redirect URI Validator” field. There you can check your redirect URIs.
I wrote a client side validation code based on the Facebook SDK.
The redirect url need you to receive the data from the facebook authentication. You will receive an object. This object consist of data about the user (name, email, profile picture… ect.) if the user successfully logged in with Facebook or you will get information about some error. So before you log in your user, you must check these data. And anyway, I think so you have to also validate because these data arrived from outside of your environment. Always validate before using.
I really don’t know how to do any experienced coder, I also just learning now and I needed to find any other alternative way for social login because my host provider don’t use node.js. So I try to develop to PHP server now.

I attach my code, maybe you can find any good idea:

Github file:
Facebook login at row 286-296.
This is still the registration procedure in my code, but the login will be exactly the same… the different will be the php file. Now I send these data to the signup. php… at login I will send to login.php …

My Social Class:
The Facebook function is at row 19-52.
As you see the response can contain information about the procedure, but this still does not mean your user successfully logged in. You have to check the result. And you can check these data in your Valid OAuth Redirect URIs file. As you see this is for me exactly the same with the file where I asked the authentication: (my index.html) https://cselko.offyoucode.co.uk/fcc/take_home/recipes/

I hope this is help to you.

1 Like

@lendoo thank you this helped!
keep safe :slight_smile:

This is good, I too bumped up onto a guide which explains step by step on implementing Facebook social login: https://www.loginradius.com/blog/async/implement-facebook-social-login/
might be helpful for beginners