Last active
May 31, 2023 17:32
-
-
Save anthonybudd/22a372581e59185fe94b83d5dab592cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('@shopify/shopify-api/adapters/node'); | |
const { shopifyApi } = require('@shopify/shopify-api'); | |
// UPDATE THESE VALUES | |
const SHOPIFY_CLIENT_ID = ''; | |
const SHOPIFY_APP_HOSTNAME = ''; | |
const SHOPIFY_CLIENT_SECRET = ''; | |
const SHOPIFY_SESSION = {}; // Add shopify oAuth session here | |
const Shopify = shopifyApi({ | |
apiKey: SHOPIFY_CLIENT_ID, | |
hostName: SHOPIFY_APP_HOSTNAME, | |
apiSecretKey: SHOPIFY_CLIENT_SECRET, | |
scopes: [ | |
'read_customers', | |
'write_customers', | |
'read_products', | |
'write_shipping', | |
'read_orders', | |
], | |
}); | |
const shopify = new Shopify.clients.Rest({ session: SHOPIFY_SESSION }); | |
// THIS WORKS RETURNS HTTP 200. THIS IS JUST TO TEST SHOPIFY_SESSION IS VALID. | |
await client.get({ path: '/admin/api/2023-04/carrier_services.json' }); | |
// THIS CODE RETURNS HTTP 403. THIS DOES NOT WORK. | |
await shopify.post({ | |
path: '/admin/api/2023-04/webhooks.json', | |
data: { | |
webhook: { | |
address: `https://my-shopify-app.com/api/v1/shopify/webhook`, | |
topic: 'orders/create', | |
format: 'json', | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment