Skip to content

Instantly share code, notes, and snippets.

@gyfchong
Last active February 8, 2021 00:32
Show Gist options
  • Save gyfchong/4efd85871217af4de1ba2a96988e57b2 to your computer and use it in GitHub Desktop.
Save gyfchong/4efd85871217af4de1ba2a96988e57b2 to your computer and use it in GitHub Desktop.
Express endpoint for generating a GetStream.io token
const { connect } = require("getstream");
// Get these values from your GetStream.io Dashboard
const client = connect(
"STREAM_KEY",
"STREAM_SECRET",
"APP_ID"
);
// Create an Express endpoint that recieves the UID for your authenticated user
app.get("/stream-token", (req, res) => {
const userId = req.headers.uid;
// Use the UID as your ID for creating the Stream Token
const streamToken = client.createUserToken(userId);
// Return the new Stream Token
res.json(streamToken);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment