Last active
February 8, 2021 00:32
-
-
Save gyfchong/4efd85871217af4de1ba2a96988e57b2 to your computer and use it in GitHub Desktop.
Express endpoint for generating a GetStream.io token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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