Registry / security / fuel-auth

fuel-auth

JSON →
library3.3.0jsnpmunverified

Node.js library for OAuth2 authentication with Salesforce Marketing Cloud (formerly ExactTarget) REST and SOAP APIs. Version 3.3.0 targets Node >= 4, uses request package for HTTP, and is ESM-only with TypeScript declarations. It simplifies obtaining access tokens using client credentials or refresh tokens. Compared to manual OAuth2 flows, it handles token caching, refresh, and error handling. The library is actively maintained by Salesforce but has limited updates for newer Node versions.

npm install fuel-auth
INSTALL
IMPORT
SIG · FUEL-AUTH
F
fuel-auth
securityjavascriptv3.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AuthClient
import { AuthClient } from 'fuel-auth'
const AuthClient = require('fuel-auth')
ESM-only since v3; no CommonJS default export.
default
import AuthClient from 'fuel-auth'
const auth = new AuthClient(options) // requires import or require
Library exports both named and default export for convenience.
AuthClient (type)
import type { AuthClientOptions } from 'fuel-auth'
const AuthClientOptions = require('fuel-auth').AuthClientOptions
TypeScript types are exported; use 'import type' to avoid runtime overhead.

Shows ES module import, instantiation of AuthClient with credentials, and obtaining an access token.

import AuthClient from 'fuel-auth'; const client = new AuthClient({ clientId: process.env.MC_CLIENT_ID ?? '', clientSecret: process.env.MC_CLIENT_SECRET ?? '', authUrl: 'https://auth.exacttargetapis.com/v1/requestToken', }); client.getAccessToken() .then((token) => { console.log('Access Token:', token.accessToken); }) .catch((err) => { console.error('Auth error:', err.message); });
Debug
Known issues
gotcharequest package is deprecated; may cause security vulnerabilities and lack of updates.
fix
Migrate to a modern HTTP client (e.g., node-fetch, axios) via a wrapper or fork.
affects: >=3.0
breakingSwitched from CommonJS (require) to ESM-only in v3. require() will not work.
fix
Use import syntax and ensure package.json has 'type': 'module' or use .mjs extension.
affects: >=3.0
deprecatedexacttargetapis.com auth URL is deprecated; use new Salesforce Marketing Cloud endpoints.
fix
Update authUrl to 'https://mc.exacttargetapis.com/v1/requestToken' or the correct v2 endpoint.
affects: >=3.0
gotchaDefault token caching is in-memory and may not be suitable for serverless or multi-process environments.
fix
Implement custom cache adapter via the 'cache' option or use a shared cache like Redis.
affects: >=3.0
Errors
Common errors & fixes
Error: Cannot find module 'fuel-auth'
CommonJS require() used on ESM-only package v3+.
fix
Switch to ES module import syntax or downgrade to v2.x.
TypeError: AuthClient is not a constructor
Importing default incorrectly when using named export.
fix
Use default import: import AuthClient from 'fuel-auth'
Error: getaddrinfo ENOTFOUND auth.exacttargetapis.com
Deprecated auth endpoint or misconfigured authUrl.
fix
Update authUrl to the correct endpoint for your region.
Error: Failed to obtain access token: 401 Unauthorized
Invalid clientId/clientSecret or expired/invalid tenant.
fix
Verify credentials in Salesforce Marketing Cloud setup.
Upgrade
Version history
3.3.0latest on npm
Audit
Dependencies
requestrequiredHTTP client for token requests
Agent activity
15 hits · last 30 days
node
14
Resources
fuel-auth — npm install fuel-auth · libregistry