开发者

Creating a Javascript Facebook Connect Session based on a valid Offline Access Key (infinite session key)

I spent an entire Saturday 开发者_JS百科exhausting Google. Serious good Karma belongs to anyone who can help.

I'm using the .NET Facebook toolkit V3 to authenticate my users against Facebook. When a user grants the offline_access permission I store the session key. When they return later without a facebook session (but with a valid session for my web app).

I grab the key from the database and I apply it to the Facebook.Session like so:

    facebookAPI.Session.SessionKey = offlineAccesSessionKey;
    facebookAPI.Session.UserId = (long)fuid;

Works like magic.

Now here's the problem:

How do I use this infinite session key with the Javascript API and FBML?

I can pass the session key to the client side, but then what? getAuth? set_session? Can't make it work, try as I may, and not sure it'd help me with the FBML.

I've tried this:

    facebookAPI.Auth.Session.UserId = (long)fuid;
    facebookAPI.Auth.Session.SessionKey = offlineAccesSessionKey;
    facebookAPI.Auth.Session.SessionSecret = _facebookAPI.Session.SessionSecret;
    facebookAPI.Auth.PromoteSession();

Hoping that it would copy the cookies, and I could pick them up on the client side, but no luck.

It seems like it must be a pretty common situation, but my "expert" Google skills are turning up ZERO.

Does anyone have any experience that can help?


From what I know, the JS API for Facebook, generates its own session for the time its being used (correct me if im wrong). That session is temporary so that wont work using its token on the server.

What you can do is to store the uid in your database along with the (infinite) token. Then using the JS API you can get the uid from the client, send to the server, then retrieve the token from database. You can then do your normal server side connection on behalf of the user.

I hope it helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜