0

i'm trying to get ChatKit to FlutterSDK, but i'm facing a little tiny problem ,, i'm sending request to ChatKit End Point ,, but i think i'm missing headers so i never get authed ,, (reponse Code 401)

so what i should use as header?

i was trying to connect via Dart Http Package

   static String _apiEndPoint =
     "https://us1.pusherplatform.io/services/chatkit/v2/:instance_id";
   static final String _usersEndPoint = "/users";

   var uri = Uri.parse("$_apiEndPoint$_usersEndPoint");
   var request = new http.MultipartRequest("POST", uri);
   request.fields['name'] = '$name';
   request.fields['id'] = '$username';
   request.fields['avatar_url'] = '$avatarUrl';
   request.fields['custom_data'] = '{"email": "$email"}';
   request.send().then((response) {
     print(response.statusCode);
   });

i thought that's enough to create user account by following docs here: https://docs.pusher.com/chatkit/reference/api#create-a-user

Saifallak
  • 1,234
  • 2
  • 13
  • 28

1 Answers1

1

You need to add a header (use request.headers['authorization'] = 'Bearer $token';) and calculate the bearer token as described here.

Richard Heap
  • 48,344
  • 9
  • 130
  • 112