开发者

Login using Facebook Problem after logging out

I am using facebook sdk and facebook connect for integrating fb into my site using asp.net and c#. The user can login using the code successfully. The problem that I face is that whenever a user is logged in thru fb; if the user logs out from the facebook's site and then tries to login through my site using fb connect, it gives error: The session is invalid because the user logged out.

I should again provide the facebook connect button to log in as it does initially but it gives error. The code used is shown below:

protected void Page_Load(object sender, EventArgs e)
{
        if (!Page.IsPostBack)
        {
            if (ConnectAuthentication.isConnected())
            {
           开发者_JS百科     Facebook.Session.ConnectSession _connectSession = new Facebook.Session.ConnectSession(ConfigurationManager.AppSettings["ApiKey"], ConfigurationManager.AppSettings["AppSecret"]);
                if (!_connectSession.IsConnected())
                {
                    lblStatus.Text = "Please sign-in with Facebook.";
                }
                else
                {
                    Facebook.Rest.Api api = new Facebook.Rest.Api(_connectSession);

                    Facebook.Schema.user user = api.Users.GetInfo();
                    string fullName = user.first_name + " " + user.last_name;
                    lblStatus.Text = fullName;
                }
            }
            else
            {
                lblStatus.Text = "Please sign-in with Facebook.";
            }
        }
}


When a user logs out the session is invalidated. You need to have the user log in again. If you don't want to do that then please request the "offline_access" extended permission during authentication. This way the user does not have to be logged-in.

FYI, you will have to move to OAuth before September 1st 2011. Facebook will ONLY support OAuth after that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜