Customer session

Get customer token


Get a valid and refreshed JWT login token. An error is thrown when the customer is not logged in or the token has expired and cannot be refreshed.

The method returns IDataApiCall with a parameterized Token to execute request.

Method name: Client.getToken()

Declaration

public static IDataApiCall<Token> getToken()

Parameters

No parameters required.

Return Value

IDataApiCall<Token> object to execute the request.

Example

IDataApiCall getTokenCall = Client.getToken();
        getTokenCall.execute(success -> onSuccess(), this::onFailure);

Refresh token


Refresh the authorization token.

Method name: Client.refreshToken()

Declaration

public static IApiCall refreshToken()

Parameters

No parameters required.

Return Value

IApiCall object to execute the request.

Example

boolean success = Client.refreshToken();

Get current UUID of a customer


Retrieve current customer UUID.

Method name: Client.getUuid()

Declaration

public static String getUuid()

Parameters

No parameters required.

Return Value

Customer’s UUID as a string.

Example

Client.getUuid()

Regenerate UUID for an anonymous customer


Regenerate UUID and clear the authentication token, login session, custom email, and custom identifier.

This operation works only if the current customer is anonymous.

The method returns true when the current customer is anonymous and the operation was successful.

Method name: Client.regenerateUuid()

Declaration

public static boolean regenerateUuid()

Parameters

No parameters required.

Return Value

Returns true if the current Customer is anonymous and the operation succeeds.

Example

boolean success = Client.regenerateUuid();

Generate UUID for anonymous customer with identifier

Gegenerate/re-generate UUID and clear the authentication token, login session, custom email, and custom identifier.

The UUID is generated from the customer identifier and the device ID. A combination of those two IDs always generates the same UUID, regardless of how many times the method is called for the combination.

Method name: Client.regenerateUuid(clientIdentifier)

Declaration

public static boolean regenerateUuid(clientIdentifier)

Parameters

Parameter Type Mandatory Default
clientIdentifier String yes -

Return Value

Returns true if the current Client is anonymous and the operation succeeds.

Example

boolean success = Client.regenerateUuid(clientIdentifier);

Change API Key dynamically


Change the API Key dynamically. If the currently saved API Key is different than provided, the authentication token will be cleared.

The customer’s UUID, login session, custom email, and custom identifier will always be cleared.

Method name: Client.changeApiKey(newApiKey)

Declaration

public static void changeApiKey(@NonNull String newApiKey)

Parameters

Parameter Type Mandatory Default Description
newApiKey String yes - New API Key

Return Value

Void type method.

Example

Client.changeApiKey(apiKey);

Destroy customer’s session


Use this method to destroy a session. All cached data is cleared and a new anonymous customer is created.

Method name: Client.destroySession()

Declaration

public static void destroySession()

Parameters

No parameters required.

Return Value

Method is void type.

Example

Client.destroySession();
😕

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