How the opensocial Gadget request works on Wave

Yesterday we had a problem with development of a gadget.

From the gadget we wanted to query a backend server running Ruby On rails. We used Json in the request, which is fairly easy to implement in Ruby and Javascript. The scenario looked like the following.

requestGadget1

We used the code which looked like the following example, which exist on the page Working with Remote Gadgets.

 function makeJSONRequest() {
      var params = {};
      params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
      // This URL returns a JSON-encoded string that represents a JavaScript object
      var url = "http://gadget-doc-examples.googlecode.com/svn/trunk/opensocial-gadgets/json-data.txt";
      gadgets.io.makeRequest(url, response, params);
    };

We had also added some of the authentication types, because we thought a problem was the authentication. Somehow the request did not get the correct response back. So we had to lookinto how the gadget workes.

My thought was the gadget just called the webserver directly. We did intercept the Gadget calls using the Live HTTP Client for Firefox. When we used it there was a call to wave-0-opensocial.googleusercontent.com. The gadgets are also hosted on this site and there are other numbers where the content is hosted.

The request looked like the following instead.

requestGadget2

So all requests to the remote server is done via the googleusercontent, which gives some advantages.

  • Using the opensocial authentication you do not need the users to login to your applications. Authentication can be done by trusting Oauth or the opensocial content (I have not research it fully yet).
  • Building an Appstore will be much easier. When you look at the code there are links to where the gadgets exists. So you could just copy the link to the XML code and then start using it. When all the gadgets have to be displayed from the googleusercontent.com servers, Google has the option of allowing certain url only to be exposed to the individuals how has paid for the service.
  • All data is cached the googleusercontent.com servers, meaning that you will get fewer requests and less load on your sever.  You can bypass the caching by following this guide.

So we learned a great deal about the architecture on this problem. Our next challange is to figure out how we can leverage the Opensocial authentication to authenticate the users on our Ruby on Rails application. If you have any pointers please let us know.

Bookmark and Share