Hey,
Ive tried it a few different ways, in my original app, which got past the automatic checks but failed the user testing I was doing this,
The main entry point for my apps was
- https://myapp/api/install
Everytime this url I would
- validate the hmac
- validate the domain
- store a record in my db with the shops info / update it if it already existed
- redirect to āhttps://{storeurl}/admin/oauth/authorize?client_id={1}&scope={2}&redirect_uri={3}&state={4}&grant_options={5}ā
This would trigger a call to the redirect url
- https://myapp/api/AuthCallback
When this url was called, everytime i would
- validate the hmac
- validate the domain
- look for a record in my db and load it
- validate the state
- make a call to get a new access token https://{shop url}/admin/oauth/access_token
- Save the token in my db
- redirect to my stores main page, with my own store identifier
I realised that i didnt need to regen an access token everytime, but it wasnt hurting anything so i left it in. This setup worked fine in dev stores for install / reinstall, with one acception (which is why i failed the human review) that was that on the initial install only, the last step, redirecting to my store would break out of the frame and load it in the same window, but outside of shopify. In this version i hadnt implemented the uninstall webhook.
To rectify the failed review, I found a post that suggested on the first install only, rather than redirecting to your app url, instead redirect to url that basically loads the app in the users store, so for my very last step I changed to direct to
I also modified my code, to track whether it was the first install or not, using the record i have in my db, navigating to this url, would cause shopify to re-initiate the auth flow, and as this wasnt the first install, this time after going through all the steps again, I would finally redirect back to my store. I tested this for install, reinstall on my dev store, and it worked perfectly - no breaking out of the frame.
But after re-submitting I now fail the automated tests. Ive tried various changes since (including using a different url on the authorize step), and they all fail the automated tests with an error like
āDuring install or reinstall we expected Oauth to be initiated at https://{store}.myshopify.com/admin/oauth/request_grant but was redirected to https://{mystoreaddress}/. Learn more about authentication in our developer documentationā
I have noticed that on the test I passed, shopify used a different store to test against, that the current āappstoretest5.ā Im not suggesting that the shopify process is broken, but I have rolled my code back and submitted again only to find that it now fails the automated tests.
To futher complicate things, I was deleteing my db records when the unistall web hook was fired, and due to the delay between the webhook being fired, it was getting fired part way through a test, causing me to delete my db record (as it had the same shopify domain) which was breaking my code. I beleive i fixed this issue, but still fail (Iāve also tried disabling the uninstall webhook to be sure)
Sorry for the long post, Im planning to re-align my code to how I had it initially - basically as per the docs and try again to get a base line and if that fails ill try my luck with shopify support.
Thanks!