I'm playing around with the FuelAuth module in Node. I want to use it to return an access token which I can use to interact with other objects via API (objects not available in the Node SDK)

My issue is that my code returns this generic error

{ message: 'Unauthorized', errorcode: 1, documentation: '' }

This is the code that i'm using...I've triple checked my client Id and Client secret are correct. Also authOrigin = auth endpoint

const sfmcAuth = new FuelAuth({
    clientId: clientId
    , clientSecret: clientSecret
    , authOrigin: authOrigin

    .then( (data) => {

2 Answers 2


Okay so i figured it out! My problem was twofold;

  1. I didn't need to use the Fuel-Auth module seperately to access the Fuel-Rest module. The fuel rest takes care of the authentication

  2. The parameters i passed into the options object when creating a new FuelRest class were slightly incorrect (had to dig in the Fuel-auth git code to figure this one out). Basically, I needed to define my authUrl as the auth endpoint + 'v2/token'. Also, I needed to pass an object called authOptions with a parameter called authVersion = 2. See below for the final code that worked

const options = {
    auth: {
        // options you want passed when Fuel Auth is initialized
        clientId: clientId,
        clientSecret: clientSecret,
        authUrl: authOrigin + 'v2/token',
        authOptions: {
            authVersion: 2
    origin: origin 

const sfmcRest = new FuelRest(options) 

    uri: `/platform/v1/endpoints`
    .then( response => {
    .catch(err => console.log(err))

As per sfmc-fuelsdk-node version 2.4, you can use the below syntax for initializing the client.

Note :- If authOrigin is defined then the library will not consider the stack value. you can pass null for it.

const client = new ET_Client(clientId, clientSecret, stack, {origin, authOrigin, soapOrigin, authOptions: { 
    authVersion: 2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .