Shopify / Shopify/shopify-app-template-node

How to receive webhooks from 3rd party

Open
#1,277 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1k
Forks
434
PR merge metrics
No merged PRs in 30d

Description

How can I receive a webhook from an external service and, assuming they have been validated, use their payload to interact with the admin API?

I have set up a new route that doesn't use the /api path and have that working, but I'm not sure how to then forward a request on to an authenticated /api route from within the Express back end.

I tried using http-proxy-middleware and also tried creating a custom app session:

    const session = await shopify.api.session.customAppSession(
      'external-service-test.myshopify.com'
    );
    data = await shopify.api.rest.Product.count({
      session,
    });

With the later, I get "error": "Missing access token when creating REST client".

Any help appreciated!

As an aside, I've spent a good amount of time scouring the docs to try and figure this out, but find the documentation for interacting with the API really confusing to follow and spread out across so many different repos and doc pages that don't provide quite enough info to easily get the whole picture. For example: https://github.com/Shopify/shopify-api-js/blob/main/docs/guides/session-storage.md#load-a-session-from-storage: in the code block there it says // getSessionFromStorage() must be provided by application but there are no examples of what that does or how to set it up.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the webhook route, the attempted customAppSession code, and the linked session-storage guide. Determine which supported flow should be documented for validating an external webhook and calling the authenticated Admin API, then make the relevant setup and storage examples complete and verifiable.

Written by the indexing model from the issue text.

Assessment

Tech stack
express, javascript
Domain
api, backend, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.