Solved

Shopify Admin API Auth authorization_code Not Being Sent In Redirect

ktbishop
Shopify Partner
20 1 3

Hi, we're noticing an issue where Shopify isn't always sending us the "code={authorization_code}" URL param when a client chooses to install our app. The example request in the docs (https://shopify.dev/docs/apps/auth/oauth/getting-started#step-4-confirm-installation)  show we should be receiving this URL param, and we have received it in previous installations for years now, but suddenly we're not receiving it anymore. This causes us to fail requesting a permanent access_token in a subsequent step. Has there been some change that is not reflected in the API docs yet? We are still receiving the "hmac" and "shop" URL params as expected, just not the "code" param.

Kyle B.
Accepted Solution (1)

SBD_
Shopify Staff
1829 269 409

This is an accepted solution.

Hey @ktbishop 

 

From the app authorization team:

 

I suspect what’s happening is that the app is already installed on the shop, so core is trying to load the app (because it’s not a fresh install from core’s perspective). The app should be handling the case where they don’t have an install record for the shop. The appropriate way to handle this case is for the app to redirect to /authorize to get a new authorization code.

 

Let me know if you get stuck!

Scott | Developer Advocate @ Shopify 

View solution in original post

Replies 3 (3)

SBD_
Shopify Staff
1829 269 409

This is an accepted solution.

Hey @ktbishop 

 

From the app authorization team:

 

I suspect what’s happening is that the app is already installed on the shop, so core is trying to load the app (because it’s not a fresh install from core’s perspective). The app should be handling the case where they don’t have an install record for the shop. The appropriate way to handle this case is for the app to redirect to /authorize to get a new authorization code.

 

Let me know if you get stuck!

Scott | Developer Advocate @ Shopify 

ktbishop
Shopify Partner
20 1 3

Hi SBD_,

 

Thanks for the response. Our app is not currently installed on the shop. The shop initially installed our app on July 20th but there was an internal failure on our side that prevented us from requesting an access token for the shop. At that point the shop uninstalled our app and awaited guidance from us. From our App History in the Partners Dashboard I can see the record of the shop uninstalling our app on July 20th. Now, when the shop tries a new installation our app Shopify does not send us an authorization code, even though we're going through the full installation workflow (including redirecting to /authorize after the shop accepts our permissions and chooses to go ahead with installation).

In our request logs we can see the initial installation from July 20th where Shopify was sending us the authorization code after we redirected to /authorize, but now when we redirect Shopify to /authorize we aren't being sent an authorization code. 

Kyle B.
ktbishop
Shopify Partner
20 1 3

Hey @SBD_ ,

 

Please disregard my previous reply. It turns out I was missing some context from our onboarding team. The shop had NOT in fact fully uninstalled our app before the subsequent retries where we were not being sent the authorization code, so this was a breakdown in communication. Thank you for your time!

Kyle B.