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
- Create a
ValidateUserRequest
object with the required tokens. - Call the
validateUser()
function using the instance of theLMChatClient
class. - 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:
Variable | Type | Description | Optional |
---|---|---|---|
accessToken | String | Token for accessing the API | |
refreshToken | String | Token for refreshing the session |
ValidateUserResponse
List of parameters for the ValidateUserResponse
class:
Variable | Type | Description | Optional |
---|---|---|---|
user | User | User data | ✔️ |
community | Community | Community data | ✔️ |
appAccess | bool | Whether user has app access | ✔️ |