Shopify admin Rest Api calls in Netlify lambda function

Trying to create a new user using the Shopify admin Api.

According to the shopify guide, I generate a string in base64 and pass in headers as Authorization property

const axios = require('axios');

exports.handler = async (event) => {
  try {
    const endpoint = `https://${process.env.GATSBY_SHOPIFY_STORE_URL}/admin/api/2021-10/customers.json`;

    const config = {
      headers: {
        'Content-Type': 'application/json',
        Authorization: `Basic ${Buffer.from(`${process.env.SHOPIFY_ADMIN_API_KEY}:${process.env.SHOPIFY_ADMIN_PASSWORD}`
        ).toString('base64')}`,
      },
    };

    const data = JSON.stringify({
      customer: {
        first_name: event.body.userName || 'Subscriber',
        email: event.body.userEmail,
        accepts_marketing: true,
        marketing_opt_in_level: 'confirmed_opt_in',
      },
    });

    const { statusCode, statusText } = await axios.post(endpoint, { data, config });

    return { statusCode, statusText };
  } catch (error) {
    return { statusCode: 404, statusText: error.message };
  }
};

Using this approach, I always get 401 code

response: {
    status: 401,
    statusText: 'Unauthorized',
    data: { 
      errors: '[API] Invalid API key or access token (unrecognized login or wrong password)'
 },
   isAxiosError: true,
}

Has anyone encountered this? If so, it would be great if they clarified. Thanks :blush: