This method logs in a user to your site and opens a session for the logged-in user on success.
Note: This method requires https.
|||loginID||string||The identifier the user uses to login to his account. Can be a simple username or an email address, decided based on the site's Login Identifier Policy.|
|||password||string||The password the user uses to login to his account. Empty passwords are invalid and are not accepted.|
|||captchaToken||string||The CAPTCHA challenge. This parameter is required only if the CAPTCHA failed login threshold in the site's policy has been reached (security.captcha.failedLoginThreshold).|
|||captchaText||string||The CAPTCHA text typed by the user. This parameter is required only if the CAPTCHA failed login threshold in the site's policy has been reached (security.captcha.failedLoginThreshold).|
|||actionAttributes||JSON object||In Gamification your users receive points for actions they perform on your site, in this case logging in 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 logs in, 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.
|||include||string||A comma-separated list of fields to include in the response. The possible values are: identities-active, identities-all, loginIDs, emails, profile, data, and irank. The default is profile so if this parameter is not used, the response will return the Profile object.|
|||loginMode||string||The type of login being performed:|
|||regToken||string||This parameter is required for completing the link accounts flow. Once the initial login has failed, call the login method with loginMode=link and the regToken returned from the initial call to complete the linking. For more information go to the social account linking guide|
|||sessionExpiration||integer||The time in seconds until the login session ends for the user. Set the parameter to 0 to end the session when the browser closes.|
|||targetEnv||string||This parameter defines your client side environment, which in return determines the server response data fields. The default value of this parameter is "browser", which means that by default you receive cookie-related data in the response. |
If your client runs on a mobile:
If you are calling this method using a Mobile SDK since version 2.15.6, this parameter is automatically set to "mobile" (there is no need to set it manually). In any other case, you should set this parameter to be "mobile".
As a result of setting the parameter to "mobile" the server response data fields will include: sessionToken and sessionSecret (instead of cookie related data). In such case, you should send the sessionToken and sessionSecret to your mobile client. On your client side, call GSAPI.setSession (using the Mobile SDK) to save them in the app's storage.
|isNewUser||Boolean||Indicates whether the user logging in is new. The parameter is returned only when it is set to "true", or when the user is missing the 'connectionIdentity' field in the DB.|
When 'RaaS' is enabled, If 'newUser == TRUE' and no required fields are missing, a 'SocialLeadToAccountNewUser' event is called and a new user is created.
If account is pending verification, a 'SocializeLeadToAccountsPendingVerification' event is fired instead.
|sessionInfo||JSON object||An object containg session information. The content of this object depends on the targetEnv parameter (see above).|
By default, if the targetEnv parameter is not set (your client environment is web), the sessionInfo object contains the the following string fields: cookieName and cookieValue.
Please create a session cookie with the name and value specified by these fields.
Alternatively, if the targetEnv parameter is set to "mobile" (your client runs on a mobile), the sessionInfo object contains the the following string fields: sessionToken and sessionSecret. Please send these fields to your mobile client. On your client side, call GSAPI.setSession (using the Mobile SDK) to save them on the app's storage.
|regToken||string||A ticket that is used to complete a registration process. The regToken is returned when there is a pending registration error, which occurs when the user did not complete the registration process, or there are missing fields in the user profile data that were defined as "required" in the Schema. The regToken is valid for one hour.|
|unverifiedEmails||array||One or more unverified emails, in case there is a pending verification error.|
A field that does not contain data will not appear in the response.
Gigya defines specific error codes and messages that are used with the Accounts API. These errors are returned with the APIs, indicating that some information is incorrect or missing.
This section describes the errors that are related to this API, the reasons for each error, and the expected next step.
Account pending registration (error code 206001) - returned when the registration process has not been finalized, or the schema defines fields as required and one or more of these fields were not passed in the registration proccess. The expected next step is: if the schema defines fields that are required and one or more of these fields are missing from the user Profile or data, call accounts.setAccountInfo. If the registration process has not been finalized, call accounts.finalizeRegistration.
- Account pending verification (error code 206002) - returned when the account has already been verified, and a user tries to log in with a loginID (usually an email address) that we have not yet verified that actually belongs to this person. When the accountOptions policy states that verifyEmail is "true", the account must be validated by using the available email addresses. When the policy states that allowUnverifiedLogin is "false", users are not allowed to login before they have verified their emails. So, in this case, when a user tries to login, and his account has not been verified yet, and verifyEmail is "true" in the policy and allowUnverifiedLogin is "false" in the policy, the "Account pending verification" error is returned. The expected next step is: call accounts.resendVerificationCode to resend a validation email to the unverified addresses associated with the account. The email format is according to the templates defined in the policy.
- Login Failed Captcha Required (error code 401020) - returned when login is attempted and the CAPTCHA threshold has been reached. The CAPTCHA threshold is set in the site Policies (security.captcha.failedLoginThreshold policy).
- Login Failed Wrong Captcha (error code 401021) - returned when login is attempted and the CAPTCHA threshold has been reached and the provided CAPTCHA text is wrong. The CAPTCHA threshold is set in the site Policies (security.captcha.failedLoginThreshold policy).
- Old password used (error code 401030) - returned when login is attempted with a password that doesn't match the current password but does match the previous one. The server will return this error with the message saying that "the password was modified on" the date when the current password was set.
- Account disabled (error code 403041) - returned when a user tries to login and the account is disabled.
- Invalid loginID (error code 403042) - returned when a user tries to perform an action that requires a login identifier (username or email) and the login ID doesn't exist in our accounts database. It is also returned if the password that is passed in the API is incorrect.
- Login identifier exists (error code 403043) - returned when email is defined as the loginIdentifier in the accountOptions policy, and the email address received from the provider exists in the system but is associated with a different user. The expected next step: call accounts.linkAccounts to merge between the account identified by the provided UID and the account identified by the provided login credentials (loginID + password).
- Under User (error code 403044) - returned when a user under the age of 13 tries to login.
- Pending password change (error code 403100) - returned when login is attempted and the password change interval has passed since the last password change. The interval is set in the security.passwordChangeInterval policy.
- Account Pending TFA Verification/Registration (error codes 403101/403102) - returned when a user calls this method and the policy (in the site Policies) requires 2-factor authentication, and the device is not in the verified device list for the account.
- Account Temporarily Locked Out (error code 403120) - returned when login is attempted and the account is locked out or the originating IP is locked out. This occurs after a set number of failed login attempts. The number is set in the site Policies - security.accountLockout.failedLoginThreshold policy and security.ipLockout.hourlyFailedLoginThreshold policy.