Wednesday, March 17, 2010

Google friend connect integration thoughts

When you have value of fcauth cookie from Google Friend Connect
but user has unjoined your site, then when you
request the data from gfc server you get the 401 error status with this message:

Anonymous requests are not allowed to fetch data
Error 401

This is an easy way to know that the fcauth cookie is not good anymore and you should delete it from the table in case you are storing that value in a table.

It also indicates that user is not a member of your site via his GFC thingy.

What is the best way to auto-login GFC user to your site? The oblivious choice is via fcauth cookie, get data from GFC server and login/create oViewer object.
But this can slow down the page load in case the GFC server is slow to respond.

A faster choice is to log him in via your own uid cookie, then add some DIV tag to your page and then have JavaScript on your page to make ajax call back to your server, on your server check with GFC server and upon success return a couple of links to the browser. The links will be to 'Friend connect settings' and 'invite friends', then have your JavaScript callback to add these links to the page

If GFC auth in unsuccessful then remove fcauth cookie from user record, indicating that user in not subscribed to your site anymore. In this case have your http response to delete the fcauth cookie so you don't have to go through this again.

The downside to this is that you have to make an extra request to server right after the page renders (via ajax this time)

No comments:

Post a Comment