Customer authentication


Register customer account


This method registers a new customer with an email, password, and optional data.

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

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

Do not allow signing in again (or signing 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 doesn’t require customer authentication.

Note: The API key must have the SAUTH_REGISTER_CLIENT_CREATE permission from the Client group.

Declared In:
lib/modules/client/client_impl.dart

Class:
ClientImpl

Declaration:

Future<void> registerAccount(ClientAccountRegisterContext context) async 

Parameters:

Parameter Type Mandatory Default Description
context ClientAccountRegisterContext yes - Object with the customer’s email, password, and other optional data

Return Value:
No value is returned.

Example:

await Synerise.client.registerAccount(clientAccountRegisterContext).catchError((error)

Confirm customer account


This method confirms a customer account with the confirmation token.

This method is a global operation and doesn’t require customer authentication.

Note: Returns the HTTP 400 status code if the account is already confirmed or 404 if the account does not exist.
Note: The API key must have the SAUTH_CONFIRMATION_CLIENT_CREATE permission from the Client group.

Declared In:
lib/modules/client/client_impl.dart

Class:
ClientImpl

Declaration:

Future<void> confirmAccount(String token) async

Parameters:

Parameter Type Mandatory Default Description
token String yes - Customer’s token provided by email

Return Value:
No value is returned.

Example:

await Synerise.client.confirmAccount(token).catchError((error)

Activate customer account


This method requests sending an email with a URL that confirms the registration and activates the account.

This method is a global operation and doesn’t require customer authentication.

Note: The API key must have the SAUTH_CONFIRMATION_CLIENT_CREATE permission from the Client group.

Declared In:
lib/modules/client/client_impl.dart

Class:
ClientImpl

Declaration:

Future<void> activateAccount(String email) async

Parameters:

Parameter Type Mandatory Default Description
email String yes - Customer’s email

Return Value:
No value is returned.

Example:

await Synerise.client.activateAccount(email).catchError((error)

Request customer account activation by pin


This method requests a customer’s account registration process with the PIN code.

This method is a global operation and doesn’t require customer authentication.

Note: The API key must have the SAUTH_PIN_CODE_RESEND_CLIENT_CREATE permission from the Client group.

Declared In:
lib/modules/client/client_impl.dart

Class:
ClientImpl

Declaration:

Future<void> requestAccountActivationByPin(String email) async {

Parameters:

Parameter Type Mandatory Description
email String yes Customer’s email

Return Value:
No value is returned.

Example:

await Synerise.client.requestAccountActivationByPin(email).catchError((error) {

Confirm customer account activation by pin


This method confirms a customer’s account registration process with the PIN code.

This method is a global operation and doesn’t require customer authentication.

Note: The API key must have the SAUTH_PIN_CODE_RESEND_CLIENT_CREATE permission from the Client group.

Declared In:
lib/modules/client/client_impl.dart

Class:
ClientImpl

Declaration:

Future<void> confirmAccountActivationByPin(String email, String pinCode) async {

Parameters:

Parameter Type Mandatory Description
pinCode String yes Code sent to a customer’s email
email String yes Customer’s email

Return Value:
No value is returned.

Example:

await Synerise.client.confirmAccountActivationByPin(email, pinCode).catchError((error) {

Sign in a customer


This method signs a customer in to obtain a JSON Web Token (JWT) which can be used in subsequent requests.

The SDK will refresh the token before each call if it is about to expire (but not expired).

Do NOT allow signing in again (or signing up) when a customer is already signed in. First, sign the customer out.

Do NOT create multiple instances nor call this method multiple times before execution.

Declared In:
lib/modules/client/client_impl.dart

Class:
ClientImpl

Declaration:

Future<void> signIn(String email, String password) async

Parameters:

Parameter Type Mandatory Default Description
email String yes - Customer’s email
password String yes - Customer’s password

Return Value:
No value is returned.

Example:

await Synerise.client.signIn(email,password).catchError((error)

Sign in a customer conditionally


This method signs a customer in to obtain a JSON Web Token (JWT) which can be used in subsequent requests.

The SDK will refresh the token before each call if it is about to expire (but not expired).

Do NOT allow signing in again (or signing up) when a customer is already signed in. First, sign the customer out.

Do NOT create multiple instances nor call this method multiple times before execution.

Declared In:
lib/modules/client/client_impl.dart

Class:
ClientImpl

Declaration:

Future<ClientConditionalAuthResult> signInConditionally(String email, String password) async {

Parameters:

Parameter Type Mandatory Description
email String yes Customer’s email
password String yes Customer’s password

Return Value:
No value is returned.

Example:

ClientConditionalAuthResult result = await Synerise.client.signInConditionally(email, password).catchError((error) {

Authenticate customer by IdentityProvider


This method authenticates a customer with OAuth, Facebook, Google, Apple, or Synerise.

If an account for the customer does not exist and the identity provider is different than Synerise, this request creates an account.

Declared In:
lib/modules/client/client_impl.dart

Related To:
ClientAuthContext
ClientIdentityProvider

Class:
ClientImpl

Declaration:

Future<bool> authenticate(ClientAuthContext clientAuthContext, IdentityProvider identityProvider, String tokenString) async

Parameters:

Parameter Type Mandatory Default Description
clientAuthContext ClientAuthContext yes - Object which contains agreements, attributes, and identifier of authorization
identityProvider ClientIdentityProvider yes - Provider of your token
tokenString String yes - Token retrieved from provider

Return Value:
true if the operation is success, otherwise it throws an error.

Example:

await Synerise.client.authenticate(clientAuthContext, identityProvider, tokenString).catchError((error)

Authenticate customer conditionally by IdentityProvider


This method authenticates a customer with OAuth, Facebook, Google, Apple, or Synerise.

Declared In:
lib/modules/client/client_impl.dart

Related To:
ClientConditionalAuthResult
ClientIdentityProvider

Class:
ClientImpl

Declaration:

Future<ClientConditionalAuthResult> authenticateConditionally(ClientAuthContext clientAuthContext, IdentityProvider identityProvider, String tokenString) async 

Parameters:

Parameter Type Optional Description
token String no Token retrieved from provider
clientIdentityProvider ClientIdentityProvider no Provider of your token
authID String yes Optional identifier of authorization
context ClientConditionalAuthenticationContext no Object which contains agreements and attributes
Note: authID parameter is used for decreasion the number of UUID refreshes so it must be unique for every customer.

Return Value:
No value is returned.

Example:

    ClientAgreements? agreements = ClientAgreements(push: false, rfid: false, wifi: false);
    Map<String, Object>? attributes;
    ClientAuthContext clientAuthContext = ClientAuthContext(authId: 'AUTH_ID', agreements: agreements, attributes: attributes);
    Token token = await Synerise.client.retrieveToken().catchError((error) {
      String errorMessage = Utils.handlePlatformException(error);
      Utils.displaySimpleAlert("error on handling api call \n $errorMessage", context);
      throw Exception(errorMessage);
    });
    String tokenString = token.tokenString;
    IdentityProvider identityProvider = IdentityProvider.oauth;
    
    ClientConditionalAuthResult result =
        await Synerise.client.authenticateConditionally(clientAuthContext, identityProvider, tokenString).catchError((error) {
      String errorMessage = Utils.handlePlatformException(error);
      Utils.displaySimpleAlert("error on handling api call: you need to be signed in to authenticate \n $errorMessage", context);
      throw Exception(errorMessage);
    });

Authenticate customer via Simple Authentication


This method authenticates a customer with Simple Authentication.

Note: The API key must have the SAUTH_SIMPLE_AUTH_CREATE from the Auth group.

Declared In:
lib/modules/client/client_impl.dart

Related To:
ClientSimpleAuthenticationData

Class:
Client

Declaration:

Future<void> simpleAuthentication(ClientSimpleAuthenticationData clientSimpleAuthenticationData, String authID) async 

Parameters:

Parameter Type Mandatory Default Description
data ClientSimpleAuthenticationData yes - Object which contains customer data
authID String yes null Required identifier of authorization
Note: authID parameter is used for decreasion the number of UUID refreshes so it must be unique for every customer.

Return Value:
No value is returned.

Check if a customer is signed in (via RaaS, OAuth, Facebook, Apple)


This method checks if a customer is signed in (via RaaS, OAuth, Facebook, Apple).

Declared In:
lib/modules/client/client_impl.dart

Class:
ClientImpl

Declaration:

Future<bool> isSignedIn() async 

Return Value:
true if the customer is signed in, otherwise returns false.

Example:

final bool result = await Synerise.client.isSignedIn().catchError((error)

Check if a customer is signed in (via Simple Authentication)


This method checks if a customer is signed in (via Simple Authentication).

Declared In:
lib/modules/client/client_impl.dart

Class:
Client

Declaration:

Future<bool> isSignedInViaSimpleAuthentication() async

Return Value:
true if the customer is signed in (via Simple Authentication), otherwise returns false.

Sign out a customer


This method signs out a customer out.

Note: This method works with every authentication type (via Synerise, External Provider, OAuth or Simple Authentication).

Declared In:
lib/modules/client/client_impl.dart

Class:
ClientImpl

Declaration:

Future<void> signOut() async

Return Value:
No value is returned.

Example:

await Synerise.client.signOut().catchError((error)

Sign out customer with mode or from all devices


This method signs out a customer out with a chosen mode and determines whether it should sign out all devices.

Available modes:

  • .signOut mode signs out the customer.
  • .signOutWithSessionDestroy mode signs out the customer and additionally, clears the anonymous session and regenerates the customer UUID.

The fromAllDevices parameter determines whether the method should notify the backend to sign out all devices.

IMPORTANT: It is an asynchronous method.

Note: This method works with every authentication type (via Synerise, External Provider, OAuth or Simple Authentication).

Declared In:
lib/modules/client/client_impl.dart

Class:
ClientImpl

Declaration:

Future<void> signOutWithMode(ClientSignOutMode mode, bool fromAllDevices) async {

Parameters:

Parameter Type Mandatory Description
mode ClientSignOutMode yes Mode of signing out
fromAllDevices bool yes Determines whether it should sign out all devices

Return Value:
No value is returned.

Example:

    ClientSignOutMode mode = ClientSignOutMode.signOutWithSessionDestroy;
    bool fromAllDevices = true;
    await Synerise.client.signOutWithMode(mode, fromAllDevices).catchError((error) {

😕

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.

Close modal icon Placeholder alt for modal to satisfy link checker