authenticateDevice method

  1. @override
Future<Session> authenticateDevice({
  1. required String deviceId,
  2. bool create = true,
  3. String? username,
  4. Map<String, String>? vars,
})
override

Implementation

@override
Future<model.Session> authenticateDevice({
  required String deviceId,
  bool create = true,
  String? username,
  Map<String, String>? vars,
}) async {
  final request = AuthenticateDeviceRequest()
    ..create_2 = BoolValue(value: create)
    ..account = (AccountDevice()
      ..id = deviceId
      ..vars.addAll(vars ?? {}));

  if (username != null) {
    request.username = username;
  }

  final res = await _client.authenticateDevice(request);

  return model.Session(
    created: res.created,
    token: res.token,
    refreshToken: res.refreshToken,
  );
}