Skip to content

Instantly share code, notes, and snippets.


nparsons08/auth-token.js Secret

Created Nov 11, 2019
What would you like to do?
// backend/src/controllers/v1/stream-credentials.js
import { chat } from '../../stream';
exports.streamCredentials = async (req, res) => {
try {
const data = req.body;
const user = Object.assign({}, data, {
id: req.user.sender,
role: 'user',
image: `${req.user.sender}`,
const token = chat.createToken(;
await chat.updateUsers([user]);
res.status(200).json({ user, token, apiKey: process.env.STREAM_API_KEY });
} catch (error) {
res.status(500).json({ error: error.message });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.