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).
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.
For more information, see Social Login.
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.
The following table lists the available parameters:
An HMAC-SHA1 signature proving the authenticity of the data.
* This parameter is required if you pass the siteUID parameter (above) with this method. See the "Security Requirements" above for more details.
The GMT time in which the request is made. The expected format is the Unix time format (e.g., the number of seconds since Jan. 1st 1970).
* This parameter is required if you pass the siteUID parameter (above) 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.
|||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.
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.
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.
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 'SocializeNotifyLoginNewUser' 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.|
This parameter defines the length of time that Gigya should keep the user's login session valid. It can be configured via Global Configuration, via an individual API call, or left empty. If no value is specified, the default values are 0 or -2, depending on whether your site uses RaaS or not (see below); Global configuration overrides the default, and setting the value via individual API calls override the global configuration.
The expected values are:
|||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 .
|||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
|user||User object||A 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). For more information, see 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. For more information about handling Gigya events, see Events.
The following code example uses authorization tokens and should be run server-side only.