Last modified 14:48, 9 Apr 2015


This API method notifies the Gigya service that the user has been logged in by the site. We recommend calling this method when a user logs into your site using your own login system (the site's username and password).


Note: This method is also supported in our REST API. It is highly recommended when possible, for security reasons, to execute this method from your server, so please refer to REST API > socialize.notifyLogin


The notifyLogin call registers a new user in the Gigya service when the siteUID parameter provided is new, or reconnects a returning user when the siteUID already exists in our records.

It is essential to call notifyLogin if you enable users in your site to add connections to social networks via Gigya (using socialize.showAddConnectionsUI or socialize.addConnection). The notifyLogin call allows Gigya to associate the current user's social connections with the User ID you have designated to this user. This association has several benefits:

  • Any connections the user makes to social networks will be associated with the site account. The social graph will automatically be available the next time the user logs in to the site.
  • In calls to socialize.getUserInfo and socialize.getFriendsInfo Gigya will return your own User ID as the UID for this user.
  • Gigya will set the isSiteUser flag for this user to 'true', thus even if this user is referred to as a friend of another user you can easily tell he is a user of your site and not just a friend of the visiting user.

 Please read more about integrating Gigya Social Sign-On and the implementation flow in our Social Sign-On developer's guide.


Security Requirements

The Gigya service supports a mechanism to verify the authenticity of the notifyLogin call. This mechanism is used to prove that the call is in fact coming from your site in order to prevent fraud.

We require every notifyLogin call to be signed using a HMAC-SHA1 signature. The "UIDSig" parameter (see the table of parameters below) is defined for this objective, and is a required parameter. Gigya verifies the authenticity of the signature to prove that it has in fact originated from your site and not from somewhere else.

Follow the instructions in Constructing a Signature to set the UIDSig parameter of the notifyLogin call, and make the API call as soon as possible after that to prevent the signature from expiring.





Method Parameters

The following table lists the params object members:

Required Name Type Description
Required siteUID string A unique identifier used by your site to identify the user. You may use the account ID that you have designated for this user in your database.
This parameter accepts up to 252 ASCII characters (it does not accept Unicode).
  UIDTimestamp string The GMT time in which the request is made. The expected format is the Unix time format (i.e. the number of seconds since Jan. 1st 1970). This parameter is required if you pass the siteUID parameter with this method. Gigya checks the time difference between the timestamp and the time on Gigya's server when the setUID request is received. If the time difference is more than 5 minutes, the request is considered forged.
  UIDSig string An HMAC-SHA1 signature proving the authenticity of the data. This parameter is required if you pass the siteUID parameter with this method. See the "Security Requirements" above for more details.


JSON object

This parameter is used to pass session information obtained from a social network, to Gigya, so that it may be used for making subsequent API calls to that network.

It consists of keys representing the providers for which to set session information and values consisting of sub-objects containing session information. For example:

      "facebook" : { "authToken" : "9187391837918237" },
      "yahoo" : { "authToken" : "kjhd0ukjhuwd", "providerUID": "BAK85htUqnLxSm"}

The provider field names may be: 'facebook', 'twitter', 'yahoo', 'messenger', 'linkedin', 'qq', 'renren', 'sina'

The fields for each sub-object are:

Required authToken The session authentication token.
Note: For Facebook this member should hold the Facebook Session Key.
  tokenSecret The session token secret.
Note: For Facebook this member should hold the Facebook sessionSecret.
  tokenExpiration The absolute time when the session token expires in UNIX time format.
  tokenExpiresIn The number of seconds until the session token expires. This will be used only if tokenExpiration is not provided.
  sessionHandle The session handle encoded in BASE64.
  sessionHandleExpiration The absolute time when the session expires in UNIX time format.
Optional providerUID The user's account ID in the provider's system. This field is required when the provider is yahoo.
  code A preliminary verification code received from the provider while establishing a session. The code is used in the process of receiving a session authentication token.


  • If this parameter is specified the call must be done over HTTPS. The siteUID parameter becomes optional.
  • Each provider requires a different set of fields for making API calls.


Optional actionAttributes JSON object In Gamification your users receive points for actions they perform on your site, in this case performing a notify login action grants the user points. Action Attributes may be used to annotate actions with additional information, such as the section of the web site that generated the action. If you set here the actionAttributes, each time a user performs a notify login action, the action also receives an attribute, for example "tv-show":"glee", which can mean that the action was performed on the "Glee" page of the site. 
actionAttributes contain a JSON object comprised of a series of attribute keys (categories) with associated values. You can also use a generic "tags" key. No more than three values can be given, they can be with a single key or each have their own key. For more information see Variants and Action Attributes. Action attributes are later used to filter GM Plugins by a certain attribute.
Example:  {"<attribute key1>": ["<attribute value1>", "<attribute value2>"],  "<attribute key2>": "<attribute value3>" }
  callback function A reference to a callback function. Gigya calls the specified function along with the results of the API method when the API method completes.
The callback function should be defined with the following signature: functionName(response).
The "Response object Data Members" table below provides specification of the data that is passed to the callback function.
  cid string A string of maximum 100 characters length. The CID sets categories for transactions that can be used later for filtering reports generated by Gigya in the "Context ID" combo box. The CID allows you to associate the report information with your own internal data. For example, to identify a specific widget or page on your site/application. You should not define more than 100 different context IDs.
Note: This parameter overrides the value of the identical parameter in Global Conf (the global configuration object). If the parameter is not set for the method, the value from Global Conf is used.
  context object A developer-created object that is passed back unchanged to the application as one of the fields in the response object.
  newUser Boolean This parameter determines whether this user is new to the site. The default value is false.
If 'newUser == TRUE', a 'SocailizeNotifyLoginNewUser' event is called and a new user is created. 
  regSource string  A string representing the source of the registration. This would typically be the URL where it took place.
  sessionExpiration integer This parameter defines the time in seconds that Gigya should keep the login session valid for the user. To end the session when the browser closes, please assign the value '0'. If this parameter is not specified, the session is valid forever.
  userInfo JSON object/string This parameter allows you to provide Gigya with a site's user profile data. This ensures consistent user experience. Gigya uses this information, for example, in plugins that show user info, such as the Chat and the Comments plugins. 
Note: when using Gigya's plugins, notifyLogin must be called with userInfo for site users who don't have a social identity in order for them to interact with the plugins.
The object may include the following fields: nickname, photoURL, thumbnailURL, firstName, lastName, gender, age, email. The comments and activity feeds require both a firstName and a lastName.
For example:
userInfo: { firstName: "David", lastName: "Blair", gender: "m", age:30 }
  timestamp string Deprecated. Please use the UIDTimestamp parameter instead.
  signature string Deprecated. Please use the UIDSig parameter instead.
  provider string Deprecated. Please use the providerSessions parameter instead.
  authToken string Deprecated. Please use the providerSessions parameter instead.
  tokenSecret string Deprecated. Please use the providerSessions parameter instead.
  tokenExpiration string Deprecated. Please use the providerSessions parameter instead.
  sessionHandle string Deprecated. Please use the providerSessions parameter instead.
  sessionHandleExpiration string Deprecated. Please use the providerSessions parameter instead.


Response Object Data Members

Field Type Description
errorCode integer The result code of the operation. Code '0' indicates success, any other number indicates failure. For a complete list of error codes, see the Error Codes table.
errorMessage string A short textual description of an error associated with the errorCode for logging purposes.
operation string The name of the API method that generated this response.
context object The context object passed by the application as parameter to the API method, or null if no context object has been passed.
user User object User object with updated information for the current user. The information also includes a list of the providers to which the user is currently connected.


Triggered Global Event

By using this method the onLogin global event is triggered (the onLogin global event is fired when a user successfully logs in to Gigya). Please refer to the onLogin event data. Note that if the onLogin global event is fired as a result of a notifyLogin() call, the provider field of the event data is set to "site". The event is guaranteed to be fired before the notifyLogin's callback is called. To register an event handler use the socialize.addEventHandlers API method. Please refer to the Events page in the Developer's Guide to learn more about how to handle events generated by the Gigya service.


Code Sample

The following code example uses authorization tokens and should be run server-side only.

var secret = 'Put your secret key here'; // Obtain your secret key from the 'Site Setup' page on Gigya's website
var yourSiteUid= 'sdfsdfsd'; // siteUID should be retrieved from your user management system

function your_b64_hmac_sha1(secret, datePlusSite) { 
    var b64Sig = ''; // Place your implementation here ... 
    return b64Sig; 
function printResponse(response) {
    if ( response.errorCode == 0 ) {
        alert('After notifyLogin');    

var dateStr = getCurrentTime();  // Current time in Unix format (i.e. the number of seconds since Jan. 1st 1970)
var datePlusSite = dateStr + "_" + yourSiteUid;
var yourSig = your_b64_hmac_sha1(secret, datePlusSite);

var params={
    providerSessions: { 
      "facebook" : { "authToken" : "Put Facebook Session Key here", tokenSecret: 'Put Facebook sessionSecret here', tokenExpiration: '657658465'},
      "yahoo" : { "authToken" : "Put your Yahoo Auth Token key here" }


  • This sample is not meant to be fully functional code. For brevity's sake, only the code required for demonstrating the API call itself is presented.
  • To run the code on your own domain, add your Gigya API key to the socialize.js URL. A Gigya API key can be obtained on the Site Dashboard page on Gigya's website. Please make sure that the domain from which you are loading the page is the same domain name that you used for generating the API key.


Page statistics
1984 view(s) and 6 edit(s)
Social share
Share this page?


This page has no custom tags.
This page has no classifications.


You must to post a comment.