401 Unauthorized POST discount_codes.json

Highlighted

This one is strange. I can successfully create a price_rule then later use the ID to try and generate a discount code by posting to [price_rule_id]/discount_codes.json and it fails using NGROK, but successful when using Express + Nginx on a production server. Here is the full 401 response:

name: 'HTTPError',
host: undefined,
hostname: 'pointsnapdemo.myshopify.com',
method: 'POST',
path: '/admin/price_rules/611530211446/discount_codes.json',
protocol: 'https:',
url: undefined,
statusCode: 401,
statusMessage: 'Unauthorized',
headers:
{ date: 'Fri, 24 Jan 2020 10:05:34 GMT',
'content-type': 'application/json; charset=utf-8',
'transfer-encoding': 'chunked',
connection: 'close',
'set-cookie':
[ '__cfduid=d657989c60aedaa9ff5d4cba5ad9211ea1579860334; expires=Sun, 23-Feb-20 10:05:34 GMT; path=/; domain=.myshopify.com; HttpOnly; SameSite=Lax',
'_secure_admin_session_id_csrf=4431fafd448273beda63f69a27558d0f; path=/admin; expires=Fri, 24 Apr 2020 10:05:34 GMT; secure; HttpOnly; SameSite=Lax',
'request_method=POST; path=/',
'_secure_admin_session_id=4431fafd448273beda63f69a27558d0f; path=/admin; expires=Fri, 24 Apr 2020 10:05:34 GMT; secure; HttpOnly' ],
'x-sorting-hat-podid': '117',
'x-sorting-hat-shopid': '7355138166',
'referrer-policy': 'origin-when-cross-origin',
'x-frame-options': 'DENY',
'x-shopid': '7355138166',
'x-shardid': '117',
'www-authenticate': 'Basic Realm="Shopify API Authentication"',
'strict-transport-security': 'max-age=7889238',
'x-request-id': '4e92f88f-67ba-47b5-b430-55b25835f0ff',
'x-shopify-stage': 'production',
'content-security-policy': 'default-src \'self\' data: blob: \'unsafe-inline\' \'unsafe-eval\' https://* shopify-pos://*; block-all-mixed-content; child-src \'self\' https://* shopify-pos://*; connect-src \'self\' wss://* https://*; frame-ancestors \'none\'; img-src \'self\' data: blob: https:; script-src https://cdn.shopify.com https://cdn.shopify.cn https://checkout.shopifycs.com https://js-agent.newrelic.com https://bam.nr-data.net https://api.stripe.com https://mpsnare.iesnare.com https://appcenter.intuit.com https://www.paypal.com https://js.braintreegateway.com https://c.paypal.com https://maps.googleapis.com https://www.google-analytics.com https://v.shopify.com https://widget.intercom.io https://js.intercomcdn.com \'self\' \'unsafe-inline\' \'unsafe-eval\'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fprice_rules%2Fdiscount_codes&source%5Bsection%5D=admin_api&source%5Buuid%5D=4e92f88f-67ba-47b5-b430-55b25835f0ff',
'x-content-type-options': 'nosniff',
'x-download-options': 'noopen',
'x-permitted-cross-domain-policies': 'none',
'x-xss-protection': '1; mode=block; report=/xss-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fprice_rules%2Fdiscount_codes&source%5Bsection%5D=admin_api&source%5Buuid%5D=4e92f88f-67ba-47b5-b430-55b25835f0ff',
'x-dc': 'gcp-us-central1,gcp-us-central1',
'cf-cache-status': 'DYNAMIC',
'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
'alt-svc': 'h3-24=":443"; ma=86400, h3-23=":443"; ma=86400',
server: 'cloudflare',
'cf-ray': '55a13092dc3ac564-ORD' } }

0 Likes

Uninstalled app removed all shop data reinstalled and everything is now working.

0 Likes