Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
how can i implement httpwebrequest login to facebook if i have the user email and password?
can somebody send me code sample?

additional information copied from comment below
I work with facebook SDK. I tried a lot of different directions. I searched online quite a few articles on the subject and found. I've seen examples on DotNetOpenAuth.
This is my code sample:
C#
var auth = new CanvasAuthorizer { Permissions = new[] { "user_about_me", "publish_stream", "video_upload", "share_item", "photo_upload", "offline_access" } };

            var fbWebContext = FacebookWebContext.Current;
            if (fbWebContext.IsAuthorized())
            {
                try
                {
                    var fb = new FacebookWebClient(fbWebContext);
                  //  var token = fb.AccessToken;  // Im Getting Token This Way When its Generated From User After Getting Extended Permission
                  //  dynamic result = fb.Get("/me");
                    long id = fbWebContext.UserId;
                }
                catch (Exception ex)
                {
                    if ("(OAuthException) Error validating access token: The session is invalid because the user logged out or because auth.expireSession was invoked." == ex.Message)
                    {
                        fbWebContext.DeleteAuthCookie();
                        Session.Clear();
                    }
                }
            }

i dont have the access token - I should get it after sign in
Posted
Updated 6-Nov-13 0:41am
v3

1 solution

This is not how CP usually works. Most important goal here is to learn and help learning.
You are supposed to try it on your own, and come here when you got stuck with something, with a concrete question about your code, design, etc.
Please have a look to What have you tried?[^] to see a good explanation about what I mean.
Don't forget people here don't get payed. And besides, if we give you a ready-to-go solution, it is not going to help you because you are not going to learn anything from it.


On the other hand... have you checked http://developers.facebook.com/[^]? You might find relevant information.
 
Share this answer
 
Comments
taltal81 6-Nov-13 4:57am    
I work with facebook SDK. I tried a lot of different directions. I searched online quite a few articles on the subject and found. I've seen examples on DotNetOpenAuth.
This is my code sample:
var auth = new CanvasAuthorizer { Permissions = new[] { "user_about_me", "publish_stream", "video_upload", "share_item", "photo_upload", "offline_access" } };

var fbWebContext = FacebookWebContext.Current;
if (fbWebContext.IsAuthorized())
{
try
{
var fb = new FacebookWebClient(fbWebContext);
// var token = fb.AccessToken; // Im Getting Token This Way When its Generated From User After Getting Extended Permission
// dynamic result = fb.Get("/me");
long id = fbWebContext.UserId;
}
catch (Exception ex)
{
if ("(OAuthException) Error validating access token: The session is invalid because the user logged out or because auth.expireSession was invoked." == ex.Message)
{
fbWebContext.DeleteAuthCookie();
Session.Clear();
}
}
}

i dont have the access token - I should get it after sign in

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900