If your sign-in provider already gives users a signed token (a JWT), your page sends that token with each question and Gridsay checks it. Nothing runs on your server. This is the JWT / OIDC method on a publishable key.
Open Auth and limits, choose the publishable key, set Method to JWT / OIDC, fill in the fields, and choose Save authentication.
| Field | What to enter |
|---|---|
| Provider | Fills in an example and says where to find each value for Clerk, Auth0, Supabase, Firebase, Amazon Cognito, Microsoft Entra ID, Okta, WorkOS or Better Auth. Nothing from it is saved; use Other for anything else |
| Signature | Where the keys that sign your tokens come from: Issuer (OIDC discovery), JWKS URL, or Shared secret (HS256) |
| Issuer URL | With discovery: your provider's https issuer. Gridsay reads its discovery document, whose issuer must equal this value exactly |
| JWKS URL | With a JWKS URL: the https address that publishes your provider's public signing keys |
| Issuer (optional) | With a JWKS URL or a shared secret: when set, the token's iss must equal it exactly |
| Audience | Required with discovery or a JWKS URL; optional with a shared secret. The token's aud must contain it. Up to 255 characters |
| User id claim | The claim that holds your user's id. sub by default; dots reach nested claims, as in user.id. Up to 100 characters |
| Shared secret | With HS256 only: after saving the method, choose Set secret and enter the secret your server signs tokens with, 32 to 8,192 characters. It is stored encrypted and never shown again. Replace secret swaps it at once: tokens signed with the old one stop working |
Several providers issue tokens with no audience by default. The Provider hints say how to add one, for example with a JWT template in Clerk or WorkOS.
A decoded token Gridsay accepts looks like this:
{ "iss": "https://auth.example.com", "aud": "gridsay", "sub": "user_123", "exp": 1796241600, "plan": "pro", "ai_quota": 300}iss must equal your issuer, when you set one.aud must contain your audience, when you set one.exp is required. A token is accepted up to 60 seconds after it expires, to allow for clock differences, and nbf is honoured when present.plan or ai_quota, can be matched by limit rules.Authorization header is Bearer followed by the token.RS256, RS384, RS512, ES256, ES384, EdDSA or PS256; shared-secret tokens use HS256 only.iss, aud, exp and nbf pass, and the user id claim is there.With discovery, Gridsay reads /.well-known/openid-configuration under your issuer to find the signing keys. Signing keys are fetched from your provider and kept for ten minutes. A token whose kid names a key not seen yet makes Gridsay fetch them again, at most once a minute. Your discovery and JWKS addresses must be public https addresses that answer within three seconds, with no redirect, and with at most 256 KiB.
The page code from the console sends the token for you; getToken is your function that returns it:
'use client'; import { createPromptResolver } from '@gridsay/mui-x-data-grid';import { DataGridPremium, GridAiAssistantPanel, useGridApiRef,} from '@mui/x-data-grid-premium';import { useMemo } from 'react'; // Inside your client component, using your own rows and columns:const apiRef = useGridApiRef();const onPrompt = useMemo( () => createPromptResolver({ url: 'https://api.gridsay.com/api/v1/datagrid/prompt', publishableKey: 'pk_gs_FAKE_EXAMPLE_DO_NOT_USE', // Your end user's token, sent as Authorization: Bearer. getToken: () => getToken(), apiRef, }), [apiRef],); <DataGridPremium apiRef={apiRef} rows={rows} columns={columns} aiAssistant onPrompt={onPrompt} slots={{ aiAssistantPanel: GridAiAssistantPanel }} showToolbar/>| Status and code | What your user sees | Why |
|---|---|---|
401 unauthenticated_user | Sign in to use the assistant. | No Authorization header; or not Bearer and a token; or a bad signature, wrong algorithm, wrong iss or aud, or an expired token; or no valid user id |
503 upstream_unavailable | The assistant is temporarily unavailable. Try again. | Your discovery or JWKS address did not answer as above, its issuer did not match, or a shared secret was never saved |
429 rate_limited | Too many attempts. Try again in N seconds. | More than 20 failed checks in a minute for this key from one client address. Successful checks and provider outages do not count |
403 forbidden | The assistant is not available right now. | No method is saved on the key |
The response's detail tells you which case it is, for example:
{ "ok": false, "statusCode": 401, "code": "unauthenticated_user", "message": "Sign in to use the assistant.", "detail": "End-user credential could not be verified. Send a fresh credential matching the issuer, audience and verification settings at /app/auth."}None of these is charged. They are listed under Refusals on Usage, not under Requests.