Customer Authentication


Register Customer account


Register a new Customer with email, password, and optional data.

This method requires the ClientAccountRegisterContext object with a Customer’s email, password, and optional data. Omitted fields are not modified.

Depending on backend configuration, the account may require activation. For details, see customer registration.

Do NOT allow to sign in again (or sign up) when a customer is already signed in. Sign the customer out first.

Do not create multiple instances nor call this method multiple times before execution. This method is a global operation and does not require authorization.

Declared In

lib/main/modules/ClientModule.js

lib/classes/models/Client/ClientAccountRegisterContext.js

Method

Synerise.Client.registerAccount(context, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
context ClientAccountRegisterContext yes - Object with the Customer’s email, password, and other optional data
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let email = "EMAIL";
let password = "PASSWORD";

let context = new ClientAccountRegisterContext(email, password); context.phone = '123456789'; context.customId = '000111';

context.firstName = 'John'; context.lastName = 'Rise'; context.sex = ClientSex.Male;

context.company = 'Synerise'; context.address = 'Marszałkowska'; context.city = 'Warszawa'; context.province = 'Mazowieckie'; context.zipCode = '00-000'; context.countryCode = 'PL';

context.agreements = new ClientAgreements({ email: true, sms: false, push: true, bluetooth: false, rfid: true, wifi: false });

context.attributes = { ATTRIBUTE_1: 'ATTRIBUTE_1' } context.tags = ['TAG_1', 'TAG_2']

Synerise.Client.registerAccount(context, function() { // success }, function(error) { // failure });

Confirm Customer account


Confirm a Client account with the confirmation token.

The Method returns the HTTP 400 status code if the account is already confirmed or 404 if the account does not exist. This method is a global operation and does not require authorization.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.confirmAccount(token, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
token string yes - Customer’s token provided by email
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.confirmAccount("TOKEN", function() {
	// success
}, function(error) {
	// failure
});

Activate Customer account


Activate a Customer with email. This method requires the Customer’s email. This method is a global operation and does not require authorization.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.activateAccount(email, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
email string yes - Customer’s email
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.activateAccount("EMAIL", function() {
	// success
}, function(error) {
	// failure
});

Sign in a Customer


Sign in a client in order to obtain the JWT token, which can be used in subsequent requests.

The token is valid for 1 hour (unless configured otherwise in Synerise) and the SDK will refresh the token before each call if it is expiring soon (but still valid).

The method requires valid and non-null email and password. Device ID is optional.

Do NOT allow to sign in again (or sign up) when a customer is already signed in. Sign the customer out first.

Do not create multiple instances nor call this method multiple times before execution. This method is a global operation and does not require authorization.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.signIn(email, password, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
email string yes - Customer’s email
password string yes - Customer’s password
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let email = "EMAIL";
let password = "PASSWORD";

Synerise.Client.signIn(email, password, function() { // success }, function(error) { // failure });

Check if a Customer is signed in


Check if a Customer is signed in (their token is authorized).

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.isSignedIn()

Return Value

true if the customer is signed in, otherwise return false.

Example

let isSignedIn = Synerise.Client.isSignedIn();

Sign out a Customer


Signing a Customer out clears the Customer’s JWT token.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.signOut()

Return Value

There is no return value.

Example

Synerise.Client.signOut();

Authenticate by OAuth


Use this method to authenticate by OAuth.

Returns the HTTP 401 status code if the provided access token and/or API Key is invalid.

Declared In

lib/main/modules/ClientModule.js

lib/classes/models/Client/ClientOAuthAuthenticationContext.js

Method

Synerise.Client.authenticateByOAuth(accessToken, clientOAuthContext, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
accessToken string yes - Token retrieved from OAuth authorization
clientOAuthContext ClientOAuthAuthenticationContext yes - Object that stores authId, agreements, and attributes
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.authenticateByOAuth(token, context, function() {
   // success
}, function(error) {
   // failure
})

Authenticate by OAuth if registered


Use this method to authenticate by OAuth with an already registered account.

Returns the HTTP 401 status code if the provided access token and/or API Key is invalid.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.authenticateByOAuthIfRegistered(accessToken, authID, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
accessToken string yes - Token retrieved from OAuth authorization
authID string no - Optional authenticationId to decrease UUID refresh frequency
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.authenticateByOAuthIfRegistered(accessToken, authID, function() {
   // success
}, function(error) {
   // failure
})

Authenticate by Facebook


Use this method to authenticate by Facebook.

Returns the HTTP 401 status code if the provided Facebook token and/or API Key is invalid.

Declared In

lib/main/modules/ClientModule.js

lib/classes/models/Client/ClientFacebookAuthenticationContext.js

Method

Synerise.Client.authenticateByFacebook(facebookToken, clientFacebookAuthenticationContext, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
facebookToken string yes - Token retrieved from Facebook SDK
clientFacebookAuthenticationContext ClientFacebookAuthenticationContext yes - Object that stores authId, agreements, and attributes
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.authenticateByFacebook(token, clientFacebookAuthenticationContext, function() {
    // success
}, function(error) {
    // failure
})

Authenticate by Facebook if registered


Use this method to authenticate by Facebook.

Returns the HTTP 401 status code if there is no account associated with the provided Facebook token.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.authenticateByFacebookIfRegistered(facebookToken, authID, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
facebookToken string yes - Token retrieved from Facebook SDK
authID string no - Optional authId to decrease the number of UUID refreshes
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.authenticateByFacebookIfRegistered(facebookToken, authID, function() {
    // success
}, function(error) {
    // failure
})

Authenticate Customer by Sign in with Apple


Use this method to sign in with Apple Sign In.

Declared In

lib/main/modules/ClientModule.js

lib/classes/models/Client/ClientAppleSignInAuthenticationContext.js

Method

Synerise.Client.authenticateByAppleSignIn(identityToken, clientAppleSignInAuthenticationContext, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
identityToken String no - Token retrieved from Sign In With Apple service
context ClientAppleSignInAuthenticationContext no - Object with authorization agreements and optional attributes
authID String no - Custom identity for authorization
success Block/Closure no - Block/closure to be executed when the operation finishes successfully
failure Block/Closure no - Block/closure to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.