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, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async {

Parameters:

Parameter Type Mandatory Default Description
context ClientAccountRegisterContext yes - Object with the customer’s email, password, and other optional data
onSuccess void yes - Function to be executed when the operation is completed successfully
onError SyneriseError yes - Function to be executed when the operation is completed with an error

Return Value:
No value is returned.

Example:

ClientAccountRegisterContext clientAccountRegisterContext = ClientAccountRegisterContext(email: email, password: password);

await Synerise.client.registerAccount(clientAccountRegisterContext, onSuccess: () {
  //onSuccess handling
}, onError: (SyneriseError error) {
  //onError handling
});

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, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async

Parameters:

Parameter Type Mandatory Default Description
token String yes - Customer’s token provided by email
onSuccess void yes - Function to be executed when the operation is completed successfully
onError SyneriseError yes - Function to be executed when the operation is completed with an error

Return Value:
No value is returned.

Example:

    await Synerise.client.confirmAccount(token, onSuccess: () {
      //onSuccess handling
    }, onError: (SyneriseError error) {
      //onError handling
    });

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,
      {required void Function() onSuccess,
      required void Function(SyneriseError error) onError}) async

Parameters:

Parameter Type Mandatory Default Description
email String yes - Customer’s email
onSuccess void yes - Function to be executed when the operation is completed successfully
onError SyneriseError yes - Function to be executed when the operation is completed with an error

Return Value:
No value is returned.

Example:

    await Synerise.client.synerise-flutter-sdkAccount(email, onSuccess: () {
      //onSuccess handling
    }, onError: (SyneriseError error) {
      //onError handling
    });

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, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async {

Parameters:

Parameter Type Mandatory Description
email String yes Customer’s email
onSuccess void yes -
onError SyneriseError yes -

Return Value:
No value is returned.

Example:

await Synerise.client.requestAccountActivationByPin(email, onSuccess: () {
  //onSuccess handling
}, onError: (SyneriseError error) {
  //onError handling
});

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, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async {

Parameters:

Parameter Type Mandatory Description
pinCode String yes Code sent to a customer’s email
email String yes Customer’s email
onSuccess void yes Function to be executed when the operation is completed successfully
onError SyneriseError yes Function to be executed when the operation is completed with an error

Return Value:
No value is returned.

Example:

    await Synerise.client.confirmAccountActivationByPin(email, pinCode, onSuccess: () {
      //onSuccess handling
    }, onError: (SyneriseError error) {
      //onError handling
    });

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, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async {

Parameters:

Parameter Type Mandatory Default Description
email String yes - Customer’s email
password String yes - Customer’s password
onSuccess void yes - Function to be executed when the operation is completed successfully
onError SyneriseError yes - Function to be executed when the operation is completed with an error

Return Value:
No value is returned.

Example:

await Synerise.client.signIn(email, password, onSuccess: () {
  //onSuccess handling
}, onError: (SyneriseError error) {
  //onError handling
});

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:

    await Synerise.client.signInConditionally(email, password, onSuccess: (ClientConditionalAuthResult result) {
      //onSuccess handling
    }, onError: (SyneriseError error) {
      //onError handling
    });

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,
    {required void Function(bool) onSuccess, required void Function(SyneriseError) onError}) 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
onSuccess void yes - Function to be executed when the operation is completed successfully
onError SyneriseError yes - Function to be executed when the operation is completed with an error

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

Example:

    await Synerise.client.authenticate(clientAuthContext, identityProvider, tokenString, onSuccess: (bool result) {
      //onSuccess handling
    }, onError: (SyneriseError error) {
      //onError handling
    });

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,
    {String? authID, required void Function(ClientConditionalAuthResult) onSuccess, required void Function(SyneriseError) onError}) async 

Parameters:

Parameter Type Optional Description
clientAuthContext ClientAuthContext no Object which contains agreements and attributes
identityProvider ClientIdentityProvider no Provider of your token
tokenString String no Token retrieved from provider
authID String yes Optional identifier of authorization
onSuccess void yes Function to be executed when the operation is completed successfully
onError SyneriseError yes Function to be executed when the operation is completed with an error
Note: authID parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.

Return Value:
No value is returned.

Example:

    Token token = Token(tokenString: "tokenString", origin: TokenOrigin.anonymous, expirationDate: DateTime;
    await Synerise.client.retrieveToken(onSuccess: (Token token) {
      token = token;
    }, onError: (SyneriseError error) {
    //onError handling
    });
    String tokenString = token.tokenString;
    IdentityProvider identityProvider = IdentityProvider.oauth;
    
    await Synerise.client.authenticateConditionally(identityProvider, tokenString, onSuccess: (ClientConditionalAuthResult result) {
      //onSuccess handling
    }, onError: (SyneriseError error) {
      //onError handling
    });

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:
ClientImpl

Declaration:

Future<void> simpleAuthentication(ClientSimpleAuthenticationData data, String authID, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async {

Parameters:

Parameter Type Mandatory Description
data ClientSimpleAuthenticationData yes Object which contains customer data
authID String yes Required identifier of authorization
onSuccess void yes -
onError SyneriseError yes -
Note: authID parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.

Return Value:
No value is returned.

Example:

    ClientSimpleAuthenticationData data =
        ClientSimpleAuthenticationData(firstName: firstName, lastName: lastName, email: email, customId: customID);
    await Synerise.client.simpleAuthentication(data, authID, onSuccess: () {
      //onSuccess handling
    }, onError: (SyneriseError error) {
      //onError handling
    });

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:

bool isSignedInBool = await Synerise.client.isSignedIn();

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.

Example:

    await Synerise.client
        .isSignedInViaSimpleAuthentication()
        .then((bool result) {
      if (result == true) {
        //result handling
      } else {
        //error handling
      }
    });

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:

    Synerise.client.signOut().whenComplete(() => {
      //onSuccess handling
    });

Sign out customer with mode or from all devices


This method signs out a customer out with a chosen mode and Determines if the method 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, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async {

Parameters:

Parameter Type Mandatory Description
mode ClientSignOutMode yes Mode of signing out
fromAllDevices bool yes Determines if the method should sign out all devices
onSuccess void yes -
onError SyneriseError yes -

Return Value:
No value is returned.

Example:

    ClientSignOutMode mode = ClientSignOutMode.signOutWithSessionDestroy;
    bool fromAllDevices = true;
    await Synerise.client.signOutWithMode(mode, fromAllDevices, onSuccess: () {
      //onSuccess handling
    }, onError: (SyneriseError error) {
      //onError handling
    });
😕

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