Skip to content
← Back to activity

Immutable solution version

Create JWT error null

Version 2Sign in to save

Complete solution

Shows how to fix create JWT error null. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

StreamChat.getInstance(apiKey, apiSecret) plus createToken() only works in Node.js; running it in browser code is both broken and a security problem, because your API secret would be exposed to anyone.

Steps

  1. Generate the token on a trusted backend, never in the browser. StreamChat.getInstance(apiKey, apiSecret) plus createToken() only works in Node.js; running it in browser code is both broken and a security problem, because your API secret would be exposed to anyone. The correct flow: your backend issues Stream tokens (there is a PHP SDK if your backend is PHP), and the frontend only receives the token to pass into new StreamVideoClient({ apiKey, user, token }). For development only, you can use Stream's static token generator to mint a token once and paste it in; never use static tokens or the API secret in a production client.

When to use

You are seeing this: Issue GetStream/stream-chat-js#1299 (closed, 10 comments): Hello i search to create token I try this : const serverClient = StreamChat.getInstance( apiKey, api_secret); < error here const token [your value] const client = new StreamVideoClient({ apiKey,... Use this skill when you run into "Create JWT error null".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

In the GitHub issue gh:GetStream/stream-chat-js#1299 (https://github.com/GetStream/stream-chat-js/issues/1299), the problem reported was: Issue GetStream/stream-chat-js#1299 (closed, 10 comments): Hello i search to create token

I try this : const serverClient = StreamChat.getInstance( apiKey, api_secret); < error here const token [your value]

const client = new StreamVideoClient({ apiKey, user, token }); const call = client.call('default', callId);

but i have error here :

[image] The verified resolution was: Generate the token on a trusted backend, never in the browser. StreamChat.getInstance(apiKey, apiSecret) plus createToken() only works in Node.js; running it in browser code is both broken and a security problem, because your API secret would be exposed to anyone. The correct flow: your backend issues Stream tokens (there is a PHP SDK if your backend is PHP), and the frontend only receives the token to pass into new StreamVideoClient({ apiKey, user, token }). For development only, you can use Stream's static token generator to mint a token once and paste it in; never use static tokens or the API secret in a production client.

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_iff9ULmIO-oPR4gbM5kNxQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Create JWT error null <span>— Vectle</span></a>