Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The Google data APIs allow web-based applications to authenticate using a method called AuthSub. The process is illustrated below and involves two stages: obtaining an authentication token (steps 1-4) and using the token to authenticate with the Google data service (steps 5-6).

  1. The web application (an OpenSocial app, in this case) sends a HTTP request to the Google Accounts page.
  2. The user is prompted to enter their username and password (or select an account that is already authenticated).
  3. The user enters their credentials or selects previously authenticated account.
  4. The user is redirected back to the application with a 'token' URL parameter.
  5. The application invokes the Google data service (Google Calendar for example) using the token for authentication.
  6. The Google data service responds.

...

Now we have another issue to work through—because through---because we did not use the

Code Block
login

...

Panel

function getUrlParam(name) {
name = name.replace(/-(/,"\\\[").replace(/\[]/,"\\\]");
var regexS = "-?&" + name + "=(^&#*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results h1. null )
return null;
else
return results1-9

...

to send a request using the Authorization header, but this header is filtered by the OpenSocial containers.Conclusionh1. While the Google data APIs allow web applications to authenticate in order to fully access the underlying data, OpenSocial applications are a different kind of application since they are "contained" in a social network. In order to use the AuthSub authentication method, some extra code is needed, but in the end it's possible to use all of the provided features. And remember, although this article has referenced the Google Calendar data API, the same technique can be applied to other Google data services supported by the JavaScript client library.Author Bioh1. Ignacio is an Argentinean software engineer, technology enthusiast, and has been passing his days working around Google products both from the inside—one inside--one year working on the Google Checkout API (including a presentation at the 2007 JavaOne conference on Google Checkout with Patrick Chanezon) and a 3 month internship—and outside—posting internship-and outside--posting in Google Checkout forums and participating in the OpenSocial trusted tester program. Ignacio has been involved in several projects that integrate with Google technology, such as helping in the creation of BuckDrop, working on the first version of OpenSocket with Dan Lester, and building BuyFast, an OpenSocial app for e-commerce. Since finishing his internship at Google, Ignacio has been working on an OpenSocial application that integrates with Google Maps and the Google Calendar API, which, incidentally, inspired him to write this article!Resources==

...