New user creation for chat feature in React Native + Firebase app

I’m creating a React Native app on Firebase and want to embed a chat feature inside it, for which I’m looking into Sendbird.

When a user logs into my app, I want to turn around and automatically create a user with access token in Sendbird. How can I do this without having to write backend code? According to Sendbird’s docs, [1] says that I need to use the API to create a user, but [2] says that API calls should not be made from client apps.

If I understand correctly, I will need to:

  • Wait for the user to log into my app.
  • Issue a Sendbird API request from a Firebase function (ie., my “backend service”) to create a user in Sendbird.
  • Receive an access token back from Sendbird.
  • Somehow send this access token back up to my app client where it would be saved into storage and used for subsequent requests via the Sendbird SDK.

Is there a way to avoid having to go through my app’s backend service? Any examples I can look at?

[1] https://sendbird.com/docs/chat/v3/javascript/guides/authentication
[2] https://sendbird.com/docs/chat/v3/platform-api/getting-started/prepare-to-use-api

Hi @Sameer_Madan Sorry for late response. I believe you still can use platform API on your client (meaning you have to include access token in your code), it’s just not designed for client side usage. Since Client SDK does not have a functionality to create a user, go ahead to use platformAPI to create a user with access token option on your client and save necessary information. Hence, you do not need any backend involvement. Hope this help!

No worries. I ended up just writing a quick Google Cloud Function to get this done.
Including my API access token in client code is not secure enough for what we’re building.

1 Like