Skip to main content

Validate User

The validateUser method is used to validate a user session. This function ensures that the user session is active and the provided access and refresh tokens are valid. This method helps maintain secure and authenticated access to the LikeMinds Chat SDK.

Steps to Validate a User Session

  1. Create a ValidateUserRequest object with the required tokens.
  2. Call the validateUser() function using the instance of the LMChatClient class.
  3. Use the response (LMResponse<ValidateUserResponse>) to check for validity or handle errors.
ValidateUserRequest request = (ValidateUserRequestBuilder()
..accessToken("ENTER_ACCESS_TOKEN")
..refreshToken("ENTER_REFRESH_TOKEN"))
.build();

final LMResponse<ValidateUserResponse> response = await lmChatClient.validateUser(request);

if (response.success) {
// Handle the validated user session
handleValidatedSession(response);
} else {
// Handle error
handleError(response);
}
tip

Ensure you securely manage and store the access and refresh tokens to prevent unauthorized access.

Models

ValidateUserRequest

List of parameters for the ValidateUserRequest class:

VariableTypeDescriptionOptional
accessTokenStringToken for accessing the API
refreshTokenStringToken for refreshing the session

ValidateUserResponse

List of parameters for the ValidateUserResponse class:

VariableTypeDescriptionOptional
userUserUser data✔️
communityCommunityCommunity data✔️
appAccessboolWhether user has app access✔️