Skip to main content

Function: nflTokenGen()

nflTokenGen(opts?): Promise<string>

Defined in: core/nfl_auth.ts:130

Return a valid api.nfl.com bearer token, minting + caching as needed.

The token is cached in-process and reused until ~2 min before its own JWT exp, then transparently re-minted — so callers never have to think about expiry or refresh. The first call (or any call after expiry / forceRefresh) mints a fresh token via the anonymous device-token grant at /identity/v3/token.

Resolution order (all overrides optional):

  1. NFL_ACCESS_TOKEN env var — returned verbatim, skipping minting + caching. Ignored if explicit credentials are passed.
  2. Credentials: explicit clientKey/clientSecret opts -> NFL_CLIENT_KEY / NFL_CLIENT_SECRET env vars -> the bundled public WEB_DESKTOP pair.

Parameters

opts?

NflTokenOptions = {}

Returns

Promise<string>