开发者

Authorizer.IsAuthorized is returning false after I have authenticated

I just started working with the Facebook SDK this weekend. I'm trying to integrate Facebook into a site. I followed the samples and documentation and got the Facebook Login button along with displaying "faces" fairly quickly (nice Toolkit).

<fb开发者_开发百科:login-button autologoutlink="true" perm="email"  show-faces="true" width="200" max-rows="1"></fb:login-button>

I would like to check if the user has already been authenticated (via Facebook). This is no different than what I've seen in many of the samples. The issue, I'm having is that in my Page_Load, the authorizer.IsAuthorized is returning False even after I authenticate (my profile picture is displayed as well). Is there something that I'm missing?

protected void Page_Load(object sender, EventArgs e)
{

    try
    { 
        Facebook.FacebookApp app = new Facebook.FacebookApp();

        Facebook.Web.Authorizer authorizer = new Facebook.Web.Authorizer(app);

        if (authorizer.IsAuthorized())
        {

        }
        else 
        {

        }
    }
    catch (Exception ex)
    {
    }
}


I used 4.1.1 version of Facebook C# SDK until I've got the same problem. Then I downloaded Version 4.2.1 and removed any Authorizer.Perms.

FacebookApp fbApp = new FacebookApp(access_token);
Authorizer fbAuth = new Authorizer(fbApp);
fbAuth.IsAuthorized();// returns true

Problem was solved.

The reason is than somehow UserId becomes 0 even you authorized application in Facebook. They resolved it. Now when you use FacebookApp(access_token) constructor, it gets UserId from access_token.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜