开发者

authorizer.IsAuthorized return true when logout in facebook for c# facebook sdk 4.2.1

I am now testing for the c# facebook and come across for the following error:

Here is the code:

        FacebookApp app = new FacebookApp();

        Authorizer authorizer = new Authorizer(app);
        System.Diagnostics.Debug.WriteLine(app.Session);
        if (authorizer.IsAuthorized())
        {
            Response.Write("userid:" + app.UserId + "<br/>");
            var me = (IDictionary<string, object>) app.Get("me");

            foreach (string key in me.Keys)
        开发者_C百科    {

                Response.Write(key +":" + me[key]+"<br/>");
            }

        }

    }

The code work fine when login to the facebook. However, when i try to logout thur the facebook web and try to access the page again, the line app.get("me") will throw acception (OAuthException) Error validating access token and the app.session is still valid.

Anything i did wrong and make the authorizer.IsAuthorized call return true even logout from facebook?

Thanks


Cookies do expire. Not sure of the official answer, but Facebook cookies do expire (unless you have requested offline access). You will have to account for that.


i believe your code above is working when you are logged into facebook because of an authenticated cookie that facebook stores on your computer, and as long as you have an authenticated cookie facebook will not complain when you try to call one of their graph api (ie. /me). but, when you log out of facebook your cookie is not longer valid. i think you need to get an access token for the user in order to make graph api calls even when the user logs out of facebook because if facebook does not find an authenticated cookie or a valid access token then facebook will give you the error. check out more infomration here:

http://developers.facebook.com/docs/authentication/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜