Scripting the Gigya Login Plug-in

| | Comments (0) | TrackBacks (1)
I've started to mess around w/ Gigya's service which abstracts away the different APIs of various identity providers (IdPs) and their protocols. The unified API is a lot simpler and doesn't require a Web application to be coded to all the various protocols (e.g., OpenID, OAuth, Faceboook Connect, etc.). On top of their API, they have created a plug-in that can be added to a Web page using a little JavaScript and allows an end user to pick an IdP that they'd like to login w/.

Things can get more sophisticated if needed. For instance, I was talking w/ David Brisebois on Twitter about the widget's default behavior of redirecting the user to a page w/ the information gleaned from the IdP tacked onto the query string. Brisebios didn't like this and would have preferred that the results be posted. This is a fair grievance IMO, and his dislike gave me the chance to kick the tires a bit. After a little JavaScript refresher (it's been years!), I came up w/ this little snipped that's based on the getting started example. I thought I'd pass it on in case it helps anyone besides me and Brisebios. The complete sample can be found in my stash, but the noteworthy part is how the onLoginEventHandler is wired up to the widget and used to create form elements dynamically like this:

function onLoad()
    var conf = { APIKey: '...'};
, {
    });, {
function onLoginEventHandler(eventObj)
    for (var f in eventObj.user)
      var el = document.createElement('input');
      el.type = 'hidden'; = f;
      el.value = eventObj.user[f];

In the future, I may be blogging about other aspects of Gigya's services and show how they can be used in conjunction w/ ADFS, PingFederate, and other sorts of things that I'm always going on about on this blog. In the meantime, if you have questions on Gigya or anything else you read about on my blog, please don't hesitate to reach out to me.