Implement OAuth flow using Shopify node and lambda functions

Implement OAuth flow using Shopify node and lambda functions

KrutiPatel87
Shopify Partner
3 0 1

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.

Replies 0 (0)