How to identify a user registered via Facebook api?

i I can not understand one thing.

There is a button on my website with the FB.login method from the facebook api JS SDK.

When a user first visits my site, clicks a button - I get some data from my Facebook profile, and then we check on my server in the database whether there is a user with this identifier or not? If not, write a new line. We also create a user profile on my website.

Now the question is, the next time a user visits our site (and presses a button if he is not logged in) - how to define it so that it matches his profile on our website? For example, to show him his profile or that he could change something in him ...

In normal authorization, we compare the password and user login in the database, there is no such possibility. AccessToken is constantly changing. Thought just checks the FB user ID, but then maybe someone can replace their FB ID and enter their profile, right?

What tricks are used in this case?

+5
source share
3 answers

Regardless of whether the user visits your site for the first time or not, you always use the FB.login method. This method checks if the user is connected to your application and gives an access token when the user accepted your application.

facebook , facebookid, facebook -. facebook , accesstoken, FB.login , javascript, , facebook docs.

FB.login(function(response) {
if (response.authResponse) {
   console.log('Welcome!  Fetching your information.... ');
   FB.api('/me', function(response) {
      console.log('Good to see you, ' + response.name + '.');
   });
 } else {
   console.log('User cancelled login or did not fully authorize.');
 }
});

facebook (response.id).

+6

Facebook, , facebook.

+1
source

All Articles