authenticateFacebook method

  1. @override
Future<Session> authenticateFacebook({
  1. required String token,
  2. bool create = true,
  3. String? username,
  4. Map<String, String>? vars,
  5. bool import = false,
})
override

#Facebook authentication

Nakama Facebook Authentication is an easy to use authentication method which lets you optionally import the player’s Facebook friends and add them to their Nakama Friends list.

Set import to true to import friends from the user's facebook account.

Implementation

@override
Future<model.Session> authenticateFacebook({
  required String token,
  bool create = true,
  String? username,
  Map<String, String>? vars,
  bool import = false,
}) async {
  final request = api.AuthenticateFacebookRequest()
    ..create_2 = api.BoolValue(value: create)
    ..sync = api.BoolValue(value: import)
    ..account = (api.AccountFacebook()
      ..token = token
      ..vars.addAll(vars ?? {}));

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

  final res = await _client.authenticateFacebook(request);

  return model.Session.fromDto(res);
}