usebruno/bruno · error · Error

EdgeGrid: accessToken is required

Error message

EdgeGrid: accessToken is required

What it means

Thrown by Bruno's Akamai EdgeGrid signing helper when the `accessToken` field is missing or blank in the EdgeGrid config. isStrPresent returns false for null/undefined/empty-string/whitespace, so any of those triggers the throw before signing begins. The EG1-HMAC-SHA256 auth header requires all three credentials.

Source

Thrown at packages/bruno-requests/src/auth/edgegrid-helper.js:42

 * @param {Object} config - EdgeGrid configuration
 * @param {string} config.accessToken
 * @param {string} config.clientToken
 * @param {string} config.clientSecret
 * @param {string} [config.baseURL] - override host the request is signed against
 * @param {string} [config.nonce] - optional nonce override
 * @param {string} [config.timestamp] - optional timestamp override
 * @param {string} [config.headersToSign] - comma-separated header names to sign
 * @param {string|number} [config.maxBodySize=131072]
 * @param {Object} request - axios request config ({ method, url, headers, data })
 * @returns {Promise<string>} Authorization header value
 */
export async function signEdgeGridRequest(config, request) {
  const { accessToken, clientToken, clientSecret, baseURL, headersToSign } = config;
  const maxBodySize = config.maxBodySize ? parseInt(config.maxBodySize, 10) : MAX_BODY_SIZE_DEFAULT;

  // Validate required fields
  if (!isStrPresent(accessToken)) {
    throw new Error('EdgeGrid: accessToken is required');
  }
  if (!isStrPresent(clientToken)) {
    throw new Error('EdgeGrid: clientToken is required');
  }
  if (!isStrPresent(clientSecret)) {
    throw new Error('EdgeGrid: clientSecret is required');
  }

  // Generate or use provided nonce and timestamp
  const nonce = isStrPresent(config.nonce) ? config.nonce : makeEdgeGridNonce();
  const timestamp = isStrPresent(config.timestamp) ? config.timestamp : makeEdgeGridTimestamp();

  // Determine the URL to sign — use baseURL's host/protocol if provided, otherwise the request URL.
  let urlToSign = request.url;
  if (isStrPresent(baseURL)) {
    const requestUrl = new URL(request.url);
    // A scheme-less baseURL like "localhost:6000" mis-parses ("localhost:" becomes the protocol
    // and the host is empty). If there's no "scheme://", borrow the request URL's scheme.

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Set config.accessToken to the Akamai API client access token string.
  2. If sourcing from a Bruno variable, verify the variable name and that the environment providing it is active.
  3. Confirm all three EdgeGrid fields (accessToken, clientToken, clientSecret) are populated before sending.

Example fix

// before
const config = { clientToken: '...', clientSecret: '...' }; // accessToken missing

// after
const config = {
  accessToken: bru.getVar('EDGEGRID_ACCESS_TOKEN'),
  clientToken: bru.getVar('EDGEGRID_CLIENT_TOKEN'),
  clientSecret: bru.getVar('EDGEGRID_CLIENT_SECRET')
};
Defensive patterns

Strategy: validation

Validate before calling

function validateEdgeGrid(cfg) {
  const missing = ['accessToken'].filter((k) => !cfg[k] || !String(cfg[k]).trim());
  if (missing.length) throw new Error('EdgeGrid missing: ' + missing.join(','));
}

Type guard

const hasAccessToken = (cfg) => typeof cfg?.accessToken === 'string' && cfg.accessToken.trim().length > 0;

Try / catch

try { await signEdgeGridRequest(config, request); }
catch (err) {
  if (/accessToken is required/.test(err.message)) { config.accessToken = bru.getVar('EDGEGRID_ACCESS_TOKEN'); }
  else throw err;
}

Prevention

When it happens

Trigger: Configuring a request with EdgeGrid auth where the accessToken field is empty, was never set, or was populated from an empty Bruno environment variable.

Common situations: Environment variable name typo (bru.getVar('access_tokn')); credentials stored in a different environment that was not selected; copy-paste left the field blank; secret was cleared.

Related errors


AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13). Data as JSON: /api/errors/fb373016d52a4975. Report an issue: GitHub.