Register Login

I am trying to implement a facebook connection to my site and I have a couple of questions.

1: Is it possible to register a user on my website using his current facebook email / password.

Let's say a user clicks on a link Register via facebook

and then he has to give me permissions to access his password, email, etc ... and after that I put this information into my own database and he will be able to login with that account by recording any time he wants, without having to give me permission at any time in the future.

2: If such registration is not possible, what other solution would be the best for me? Because I need to somehow track that user who is logged in with facebook, because he can upload photos, send messages, etc.

Anyway, I'm pretty new to facebook and stuff like that, so I'm really lost here, hope someone can help me :)

EDIT Thanks everyone for the great answers that helped me a lot, now all that's left is to read the documentation :)

+3


source to share


4 answers


Yes, it is possible to get information from the user. But this is quite difficult when you have never done it.

First, you need to send the following link to the user:

https://m.facebook.com/dialog/oauth?client_id=your-client-id&redirect_uri=xxx&scope=listof-information-you-want

      

Facebook will then revert your customer back to the specified uri, if the user rejected it, it will give a reason. If not, you will get the urlencoded code.

This code is required for the next step: requesting an access token:

https://graph.facebook.com/oauth/access_token?redirect_uri=xxx&client_id=xxx&client_secret=xxx&code=xxxx

      



This will return an access token if authorization has not completed.

After that, you can request the required information:

https://graph.facebook.com/me?method=GET&metadata=true&format=json&access_token=access_token

      

This will include a facebook uid that is unique to all users. Save it and you can distinguish between case and login.

This is roughly the same for any oauth2 application.

Facebook will not re-ask for permissions after the user grants them to you. This way you can store the access token and reuse it for the backend, and also use the same procedure you use to register for login.

+6


source


  • You can never access a user's password from Facebook even with their permission, so the user always needs to authenticate with Facebook and Facebook will give you the user ID of the logged in user after successful authentication. You can store all kinds of other data locally, but not enough to authenticate the user yourself.

  • Once the user is authenticated, you will have access to the Facebook user ID through the API, which should be enough to connect all kinds of information to that particular user.



+3


source


Facebook does not provide access to accounts when passwords are taken from your controls. It provides it with its own canvas for login information. Therefore, you cannot use your first approach for storing passwords in your databases. Check it out .

However, you can store email addresses after a user logs into their account using the sdks framework. Check this link for some sample C # SDK code example. You can use the Facebook APIs to fetch your email user id, photos, friends, and other information, and then play around accordingly.

+2


source


  • You won't get access to the users password - only via email if you ask for it.

  • The best way would be to have a table of users and their Facebook account id.

If you want to allow users to subscribe without Facebook, you have a nullable field for their password and facebook id, as well as a username field that you can fill in with Facebook if they sign up using this route.

+1


source







All Articles