## 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

1. 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.
