Search code examples
node.jsfirebasereact-nativegetstream-io

proper user creation flow with GetStream.io and firebase?


I am new to getStream.io and I am trying to understand a user creation flow with getstream.io and firebase. If I create a new user in firebase and then pass in their firebase UID to functions such as:

client = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET');

//generate new user
client.user('<FIREBASE UID>').create({name: "Jane Doe", occupation: "Software Engineer", gender: 'female'});

//generate token for the user
const userToken = client.createUserToken('<FIREBASE UID>');

//Allow user to follow a feed
timeline_feed_1.follow('user', '<FIREBASE UID>');

//Check followers for the user
<FIREBASE UID>.followers({limit: '10', offset: '10'});

Would this work or am I going about this all wrong?

Thank you for reading!

P.S I have looked at Users auth and profiles in getstream.io and just wanted to clarify that my firebase example is what was meant by "Stream is best used in combination with an application"


Solution

  • It looks like Stream is best used in combination with an application in the answer you referenced was about using Stream API on a server and authenticate users there and then provide your frontend code with a user token after successful authentication.

    Stream API client initialised using user tokens has restricted access in terms of which feeds are accessible or writable.

    It is not recommended to put API secret in your frontend code as it may lead to unauthorised access to other users' data if someone extracts it from your app.