GET on just created recurring charge failed with 401

Highlighted
New Member
10 0 0

 

E C (Shopify Apps Team)

Jan 8, 14:34 EST

Hi Sanjay,

I've encountered another error while testing your app, see screen recording,  and am prevented from further testing.

 

App reviewer got the error post confirmation of a recurring charge because our server got 401 on a GET call after successfully creating a recurring charge. This GET is done before activating the charge post-confirmation. Can someone on Shopify side help find why this happened? We normally do not get this. Here is the log. Thanks in advance.

 

020-Jan-08 11:16:44,256 [http-bio-8080-exec-126] com.wavelety.shopify.common.ShopifyBillingService  DEBUG createRecurringCharge url=https://K:S@thronedroom.myshopify.com/admin/api/2019-10/recurring_application_charges.json

2020-Jan-08 11:16:44,814 [http-bio-8080-exec-126] com.wavelety.common.utils.HttpUtils  DEBUG readResponse: response={"recurring_application_charge":{"id":12317196420,"name":"Shopify PASS","api_c\
lient_id":3244181,"price":"49.00","status":"pending","return_url":"https:\/\/engage.colligso.com\/shopify\/billing_callback?appId=121fb2b55c512390bf6df39c14e4a58b\u0026shop=thronedroom.myshopify\
.com","billing_on":null,"created_at":"2020-01-08T14:16:44-05:00","updated_at":"2020-01-08T14:16:44-05:00","test":true,"activated_on":null,"cancelled_on":null,"trial_days":30,"trial_ends_on":null\
,"decorated_return_url":"https:\/\/engage.colligso.com\/shopify\/billing_callback?appId=121fb2b55c512390bf6df39c14e4a58b\u0026charge_id=12317196420\u0026shop=thronedroom.myshopify.com","confirma\
tion_url":"https:\/\/thronedroom.myshopify.com\/admin\/charges\/12317196420\/confirm_recurring_application_charge?signature=BAh7BzoHaWRsKwiEgCneAgA6EmF1dG9fYWN0aXZhdGVG--c7776cc3d6b77ad048d9db55\
0ed39b16de9b7e9b"}}

2020-Jan-08 11:16:44,815 [http-bio-8080-exec-126] com.wavelety.shopify.common.ShopifyBillingService  DEBUG createRecurringCharge: created recurring charge=RecurringApplicationCharge [id=12317196\
420, name=Shopify PASS, apiClientId=3244181, price=49.00, status=pending, returnUrl=https://engage.colligso.com/shopify/billing_callback?appId=121fb2b55c512390bf6df39c14e4a58b&shop=thronedroom.m\
yshopify.com, billingOn=null, createdAt=2020-01-08T14:16:44-05:00, updatedAt=2020-01-08T14:16:44-05:00, cappedAmount=null, terms=null, test=true, activatedOn=null, cancelledOn=null, trialDays=30\
, trialEndsOn=null, decoratedReturnUrl=https://engage.colligso.com/shopify/billing_callback?appId=121fb2b55c512390bf6df39c14e4a58b&charge_id=12317196420&shop=thronedroom.myshopify.com, confirmat\
ionUrl=https://thronedroom.myshopify.com/admin/charges/12317196420/confirm_recurring_application_charge?signature=BAh7BzoHaWRsKwiEgCneAgA6EmF1dG9fYWN0aXZhdGVG--c7776cc3d6b77ad048d9db550ed39b16de\
9b7e9b, additionalProperties={}] for shopId=thronedroom.myshopify.com appId=121fb2b55c512390bf6df39c14e4a58b

2020-Jan-08 11:16:44,817 [http-bio-8080-exec-126] com.wavelety.shopify.webhook.ShopifyOAuthServlet  DEBUG onboarding done, redirecting to https://thronedroom.myshopify.com/admin/charges/12317196\
420/confirm_recurring_application_charge?signature=BAh7BzoHaWRsKwiEgCneAgA6EmF1dG9fYWN0aXZhdGVG--c7776cc3d6b77ad048d9db550ed39b16de9b7e9b ...


...after confirmation...


2020-Jan-08 11:17:08,899 [http-bio-8080-exec-131] com.wavelety.shopify.common.ShopifyBillingService  DEBUG getRecurringCharge url=https://K:S@thronedroom.myshopify.com/admin/api/2019-10/recurring_application_charges/12317196420.json

2020-Jan-08 11:17:10,930 [http-bio-8080-exec-131] org.apache.http.client.protocol.ResponseProcessCookies  WARN  Invalid cookie header: "Set-Cookie: _secure_admin_session_id_csrf=083ad1f200623cd7\
90f96a1a879bffef; path=/admin; expires=Wed, 08 Apr 2020 19:17:10 -0000; secure; HttpOnly; SameSite=Lax". Invalid 'expires' attribute: Wed, 08 Apr 2020 19:17:10 -0000

2020-Jan-08 11:17:10,931 [http-bio-8080-exec-131] org.apache.http.client.protocol.ResponseProcessCookies  WARN  Invalid cookie header: "set-cookie: _secure_admin_session_id=083ad1f200623cd790f96\
a1a879bffef; path=/admin; expires=Wed, 08 Apr 2020 19:17:10 -0000; secure; HttpOnly". Invalid 'expires' attribute: Wed, 08 Apr 2020 19:17:10 -0000

2020-Jan-08 11:17:10,931 [http-bio-8080-exec-131] com.wavelety.common.utils.HttpUtils  ERROR GET failed on https://K:S@thronedroom.myshopify.com/admin/api/2019-10/recurring_application_charges/12317196420.json, response=HttpResponseProxy{HTTP/1.1 401 Unauthorized [Date: Wed, 08 Jan 2020 19:17:10 GMT, Content-Type: applicatio\
n/json; charset=utf-8, Transfer-Encoding: chunked, Connection: keep-alive, Set-Cookie: __cfduid=d83504bedbad2587c87d7accbb8a692611578511030; expires=Fri, 07-Feb-20 19:17:10 GMT; path=/; domain=.\
myshopify.com; HttpOnly; SameSite=Lax, X-Sorting-Hat-PodId: 131, X-Sorting-Hat-ShopId: 30300176516, Referrer-Policy: origin-when-cross-origin, X-Frame-Options: DENY, X-ShopId: 30300176516, X-Sha\
rdId: 131, WWW-Authenticate: Basic Realm="Shopify API Authentication", Strict-Transport-Security: max-age=7889238, Set-Cookie: _secure_admin_session_id_csrf=083ad1f200623cd790f96a1a879bffef; pat\
h=/admin; expires=Wed, 08 Apr 2020 19:17:10 -0000; secure; HttpOnly; SameSite=Lax, X-Shopify-Stage: production, Content-Security-Policy: default-src 'self' data: blob: 'unsafe-inline' 'unsafe-ev\
al' 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.c\
om 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 htt\
ps://widget.intercom.io https://js.intercomcdn.com 'self' 'unsafe-inline' 'unsafe-eval'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=show&source%5Bapp%5D=Shopify&source%\
5Bcontroller%5D=admin%2Frecurring_application_charges&source%5Bsection%5D=admin_api&source%5Buuid%5D=a22fef49-fa5e-41d8-ade9-1963d8b42026, X-Content-Type-Options: nosniff, X-Download-Options: no\
open, X-Permitted-Cross-Domain-Policies: none, X-XSS-Protection: 1; mode=block; report=/xss-report?source%5Baction%5D=show&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Frecurring_applic\
ation_charges&source%5Bsection%5D=admin_api&source%5Buuid%5D=a22fef49-fa5e-41d8-ade9-1963d8b42026, X-Dc: gcp-us-east1,gcp-us-central1,gcp-us-central1, X-Request-ID: a22fef49-fa5e-41d8-ade9-1963d\
8b42026, set-cookie: _secure_admin_session_id=083ad1f200623cd790f96a1a879bffef; path=/admin; expires=Wed, 08 Apr 2020 19:17:10 -0000; secure; HttpOnly, CF-Cache-Status: DYNAMIC, Expect-CT: max-a\
ge=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct", Server: cloudflare, CF-RAY: 552082962a5fd39a-LAX] ResponseEntityProxy{[Content-Type: application/json; charset\
=utf-8,Chunked: true]}}
0 Likes
Highlighted
Shopify Staff (Retired)
Shopify Staff (Retired)
624 103 124

Hey @sdatshop ,

 

A 401 error from Shopify on a GET Request means that the request was Unauthorized.

 

I'd recommend you to go over the Shopify API docs on Authorization to familiarize yourself on how to authorize a public app. Alternatively, you could look into building your app with a library like the shopify_app Ruby gem or the koa-shopify-auth to handle the authentication process for you. 

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes