Social Login JavaScript API: Events

The Social Login solution supports client-side handling of a number of events. These are useful for making customizations based on information gathered at run time, and for using third-party analytics to track specific events.

To handle events generated by Social Login, register your event handlers within the janrainWidgetOnload function. Each of the following event objects has an addHandler method that takes a single function reference as an argument. An event can have any number of handlers; each one is called when the event occurs.

The following examples show how to register event handlers. See the Janrain-Sample-Code Github repo for more. Here is a full example of using the Janrain event system to send data to a third-party analytics site such as Google Analytics.

The following fields in the janrain.events object define events

onModalWidgetReady

Fires when the modal window is ready.

onReturnExperienceFound

Occurs when a user returns to the site after signing in previously and the UI presents itself in a simplified form. It assumes the user plans to sign in with the same provider and user name.

An object containing the following fields:

  • returnProvider A string identifying the identity provider previously used. 
  • welcomeName The user’s name, as it appears in the “welcome back” message.

onProviderLoginStart

Occurs when the user clicks the provider or return experience button, beginning the sign-in process. Object with single field indicating provider chosen.

onProviderLoginError

Occurs when encountering an error during the sign-in process.

An object containing the following fields:

  • err - Error object.
  • code - Numeric error code.
  • msg - Descriptive error string.
  • origin - Origin of sign-in error.
  • stat - Status message.

Error Codes

These error codes are specific to the Social Login solution and describe error states that arise from users attempting to sign in.

The error codes and descriptions are returned when the onProviderLoginError event occurs. The event returns an object containing the error details.

  • 100 Please enter your screen name
  • 101 Your OpenID must be a URL
  • 102 Your OpenID must be a URL
  • 103 Unable to contact your OpenID
  • 104 The OpenID you entered was not found
  • 105 There was an error looking up your OpenID
  • 106 Use a different OpenID server
  • 107 The URL you entered does not appear to be an OpenID
  • 108 Discovery failed for the OpenID you entered
  • 109 SSL verification failed for your OpenID
  • 132 Bad response from the OpenID server
  • 134 SSL verification failed for OpenID endpoint
  • 135 The FICAM authentication response verification failed
  • 136 The provider is not FICAM certified
  • 200 The token URL or xdReceiver has not been whitelisted
  • 201 The provider is not configured
  • 202 Error contacting the provider
  • 203 Invalid account
  • 204 The Provider does not support the requested scope (permissions)
  • 205 Error response from the provider

onProviderLoginSuccess

Occurs when the user successfully signs in.

onProviderLoginComplete

Occurs when the sign-in process is complete, whether successful or not.

onProviderLoginToken

Occurs when the user successfully signs in, and the tokenAction setting is true. A response object containing a single token field; this contains the one-time token.

onProviderLoginCancel

Occurs when the end user clicks the Cancel or No Thanks button on the login screen. Some identity providers do not include a Cancel button or their cancel message does not get passed to Social Login. You may encounter issues with these providers:

  • AOL
  • Disqus
  • Flickr
  • Foursquare
  • Linkedin
  • LiveJournal
  • Renren
  • Tumblr
  • Twitter
  • Verisign
  • WordPress
  • Yahoo!

This event is fired from inside the cancelLogin call.

onProviderLogoutStart

Fires when the user begins the sign-out process.

Object with a single field (indicating provider).