App uninstalled hook cannot use access token

Ari9
Excursionist
35 3 10

I'm working on an app which injects code into the product.liquid theme file itself.

Upon the `app/uninstalled` webhook, I'd like to clean up this snippet injected by my app, but the user's access token for the store seems to be unusable the moment they uninstall the app. This leaves my snippet left in the theme and most users will not know how / want to clean it up from the theme file manually.

Is there any way I can modify the file on uninstall to perform some cleaning up?

Replies 9 (9)
Arhum
Excursionist
23 2 8

Hi, I am working on similar thing. My app creating product on app install and wanted to delete that product on app uninstall. 

https://community.shopify.com/c/Shopify-APIs-SDKs/Delete-Product-on-App-Uninstalled/m-p/1184278#M673...

 

At above link i found out that it is not possible. You can send email to customer or do it manually(i know that is not possible).

Reason is same which you told that when app delete from store, shopify block access for that acess_token.

 

if You find anything please let us know.

Thanks

Ari9
Excursionist
35 3 10

Thanks @Arhum !

That's such a shame. It would be very inconvenient for customers to do, especially if they are not experienced with editing the code themselves.

In my case, I guess the only solution is to move the injected snippet into JavaScript using the script_tags API which is automatically deleted by Shopify when the app is uninstalled.

 

For any Shopify staff seeing this, it seems quite important to give apps access to the access token, even if it's 5 minutes after the app is installed. I hope it can be considered - Thanks!

 

 

Arhum
Excursionist
23 2 8

Yes. Exactly. I hope they see this post and consider this issue. This feature can help to maintain cleanliness of customer store as well.

orloff
Shopify Partner
24 0 13

Confirm it!

In app/uninstall webhook session token not valid for any API request

oneluca
Tourist
9 1 5

+1 

ldelafuente
New Member
1 0 0

At this point it doesn't surprise me that the Shopify technical team (not support team) won't answer this post.

Lacking documentation, outdated packages, and no information how to perform these simple tasks nor if they have any intention of implementing a solution.

Still looking for a solution to this problem.

+1

stratify
Shopify Staff (Retired)
Shopify Staff (Retired)
20 2 12

Hey Team – my names Strat, Frontend Developer at Shopify!

 

I understand you'd like to remove app content from a theme after the app has been deleted. As you've noted, apps no longer have permissions to edit a theme once merchants decide to delete the app. I understand how that can be frustrating when you want to clean up your data. Shopify cannot provide access after merchants have decided to revoke it – we need to respect that decision.

 

As a result, we don't provide options for updating themes after an app has been removed, but you do have some options:

  • It's always a good idea to scope your app's functionality or code with the ScriptTag API. This lets you add functionality to Online Store pages without using theme templates.
  • Similarly, you can use Theme App Extensions to securely surface your app’s functionality on a merchant's online store. App extensions inject sections and snippets into a theme, and the content is removed from themes automatically when the app is uninstalled.

I hope that's helpful moving forward!

MichaelCo
New Member
1 0 0

@stratify - All the links that appears in your response are not working any more. 

stratify
Shopify Staff (Retired)
Shopify Staff (Retired)
20 2 12

Thanks @MichaelCo – I've updated my comment with links to our developer docs 🙂