authenticateDevice method
Device authentication
Nakama Device Authentication uses the physical device’s unique identifier to easily authenticate a user and create an account if one does not exist.
When using only device authentication, you don’t need a login UI as the player can automatically authenticate when the game launches.
Implementation
@override
Future<model.Session> authenticateDevice({
required String deviceId,
bool create = true,
String? username,
Map<String, String>? vars,
}) async {
final res = await _api.v2AccountAuthenticateDevicePost(
body: ApiAccountDevice(id: deviceId, vars: vars),
create: create,
username: username,
);
if (res.body == null) {
throw Exception('Authentication failed.');
}
final data = res.body!;
return model.Session.fromApi(data);
}