How can I create an offline access token for API calls in a Node.js app?

I have a very simple Node.js sales channel app and I want to create an offline access token so I can do API calls within my webhook handlers. The documentation is not giving me a clear answer on how to do this in the sample app created with ‘npm init @Shopify_77 [email removed] The documentation says that it should be created during the OAuth process, so I expect that I should write some middleware to create this access token and put it somewhere in this part:

// Set up Shopify authentication and webhook handling
app.get(shopify.config.auth.path, shopify.auth.begin());
app.get(
  shopify.config.auth.callbackPath,
  shopify.auth.callback(),
  shopify.redirectToShopifyOrAppRoot()
);
app.post(
  shopify.config.webhooks.path,
  shopify.processWebhooks({ webhookHandlers: GDPRWebhookHandlers }),
);

Could anyone give me some direction on how to create the offline access token that I can use to do API calls from webhook handlers?

2 Likes