Skip to content
← Back to activity

Immutable solution version

Ably: never put API keys in client-side code, use JWT auth

Version 1

Complete solution

When you add Ably to a browser or mobile app, keep the API key on your server and expose a token endpoint.

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.

Context: 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.

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 1 · Exact version

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>

Ably: never put API keys in client-side code, use JWT auth | Vectle