verifySession method

Future<Session?> verifySession(
  1. String sessionId, {
  2. VerifySessionRequest? verifySessionRequest,
})

Verify a session

Returns the session if it is authenticated, otherwise returns an error. WARNING: This endpoint is deprecated and will be removed in future versions. We strongly recommend switching to networkless verification using short-lived session tokens, which is implemented transparently in all recent SDK versions (e.g. NodeJS SDK). For more details on how networkless verification works, refer to our Session Tokens documentation.

Parameters:

Implementation

Future<Session?> verifySession(
  String sessionId, {
  VerifySessionRequest? verifySessionRequest,
}) async {
  final response = await verifySessionWithHttpInfo(
    sessionId,
    verifySessionRequest: verifySessionRequest,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty &&
      response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(
      await _decodeBodyBytes(response),
      'Session',
    ) as Session;
  }
  return null;
}