Implement OAuth flow using Shopify node and lambda functions

Topic summary

Implementing Shopify OAuth in AWS Lambda using the shopify-api-node library. In Lambda test invocations, the event has headers and shop name but event.body is null, leaving no request/response objects for Shopify.Auth.beginAuth.

  • Environment: Node.js on AWS Lambda; local testing via ngrok works and provides request/response.
  • Code: Initializes Shopify Context, then calls Shopify.Auth.beginAuth(request, response, shop, ‘/auth/callback’, false) and issues a 302 redirect. The required request/response objects are missing in Lambda.

Key issue/questions:

  • How to obtain or construct Node-style request/response from the Lambda event/context (e.g., via API Gateway proxy integration or an adapter) to pass into beginAuth.
  • Whether API Gateway configuration is needed to ensure body is forwarded (proxy integration, payload format, binary/base64 settings, or body parsing).

Status: No resolution yet; seeking guidance on mapping Lambda/APIGW event to the request/response expected by the Shopify auth flow. The included code snippet is central to understanding the problem.

Summarized with AI on February 9. AI used: gpt-5.

I am trying to implement Shopify authentication using node js library (https://github.com/Shopify/shopify-api-node) and lambda functions.

When I am trying to test the flow I am receiving body = null in the event object, is there anything I need to configure to get the body or request or response details from Shopify? I am getting headers and shop name in the event.

I need to call beginAuth method to initialize the flow, but from where I can get request and response? Is it possible to get it from event?

exports.handler = async function(event, context, callback){
console.log('Received event:', JSON.stringify(event, null, 2));

    ShopifyClient.Shopify.Context.initialize({
        API_KEY: process.env.API_KEY,
        API_SECRET_KEY: process.env.API_SECRET_KEY,
        SCOPES: process.env.SCOPES.split(" "),
        HOST_NAME: process.env.DOMAIN_NAME,
        API_VERSION: ApiVersion.July22,
        IS_EMBEDDED_APP: true
    });
	
	const authRoute = await Shopify.Auth.beginAuth(
		request,
		response,
		shop,
		'/auth/callback',
		false
	)

	response.writeHead(302, {Location: authRoute});
	response.end();
}

I am able to test the authentication flow in the local environment by using ngrok and I am getting request and response details when I test the app.

Only having issues when trying to implement via lambda.