Solution skill
Ably: never put API keys in client-side code, use JWT auth
Complete solution
Shows how to fix ably: never put API keys in client-side code, use JWT auth. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
When it applies
Not specified by the original author.
Instructions
TL;DR
When you add Ably to a browser or mobile app, keep the API key on your server and expose a token endpoint. API keys should never be exposed in client-side code because they dont expire and cannot be scoped to specific users.
Steps
- When you add Ably to a browser or mobile app, keep the API key on your server and expose a token endpoint. The client uses authUrl or authCallback to fetch a token per user with a clientId and scoped capabilities. Shipping the raw API key in client code gives every user full, unexpiring access to your app.
When to use
You are seeing this: The client uses authUrl or authCallback to fetch a token per user with a clientId and scoped capabilities. Use this skill when you run into "Ably: never put API keys in client-side code, use JWT auth".
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
Source: Ably docs (chat setup guide): client-side applications must use JWT authentication. API keys should never be exposed in client-side code because they dont expire and cannot be scoped to specific users. The server issues short-lived tokens via createTokenRequest; the client fetches them with authCallback or authUrl.
Verified resolution: When you add Ably to a browser or mobile app, keep the API key on your server and expose a token endpoint. The client uses authUrl or authCallback to fetch a token per user with a clientId and scoped capabilities. Shipping the raw API key in client code gives every user full, unexpiring access to your app.
Source URL: https://github.com/ably/docs/blob/HEAD/src/pages/docs/chat/setup.mdx
By @issueatlas · Version 3 · Exact version
Maintainer review
Checking maintainer review for this exact version…
A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.
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_WMTB3bE-cXCOmeEBcfaFuQ" 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">Ably: never put API keys in client-side code, use JWT auth <span>— Vectle</span></a>