I have been digging on facebook authentication for a week. I came across so many things such as facebook_connect, Facebook C# SDK from CodePlex and other ways to connect with facebook which are absolute now. Finally after reading http://developers.facebook.com for many times, I did manage to have a login button and get user's information for facebook using the new and standard Graph API stuffs. There are in Javascript such as.

var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
var name = response.name
var username = response.username
var gender = response.gender

On another world, I have Login Control and asp.net Form authentication managing the whole website.

Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate

Dim userName As String = Login1.UserName
Dim password As String = Login1.Password
Dim result As Boolean = UserLogin(userName, password)
If (result) Then
    e.Authenticated = True
Else
    e.Authenticated = False
End If
End Sub

Private Function UserLogin(ByVal userName As String, ByVal password As String) As Boolean
    //validate user // if valid, return true
    //return false if invalid user
End

I can't remove all form authentication from the existing website. Facebook login should be value added feature to the website. Now the few bits I don't get is ...

  1. How to authenticate the asp.net Form authentication when someone Login to the website using facebook Login.
  2. How do I pass all the value in the javascript to aspx.vb to connect to database and store the information.

I understand I would need to create a new table in the database, probably called FacebookUsers. But I can't think a way that facebook authentication and asp.net Login control to work together. My website is in VB.net by the way.

有帮助吗?

解决方案

  1. *How do I pass all the value in the javascript to aspx.vb to connect to database and store the information*. Check out the following articles they may help you out a bit. http://www.codeproject.com/Tips/371917/Get-user-Facebook-details-in-ASP-NET-and-Csharp

1.-Don't create a new table just add a new field to your current users table... 2.-Name the Field FaceBookUID or FB_ID. 3.-Store the facebook user id . 4.-Set the default Value of the FACEBOOK UID to 0. 5.-Now you'll have a unique value between a regular user and a FacebookUser.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top