I’m trying to move to Shopify-Managed installation and implement dynamic scope requests using the App Bridge scopes API to request optional scopes without requiring merchants to go through a full OAuth redirect flow.
However, I’m getting this error when calling the API:
Error occurred when attempting to request access scopes: RequestGrantUserError: The app does not have scopes declared on Shopify.
My Setup:
- Previously had use_legacy_install_flow = true in my shopify.app.toml
- Removed the legacy flag and added optional scopes:
[access_scopes]
scopes = "read_script_tags,write_script_tags,read_products,read_orders,read_translations,write_discounts,read_discounts,read_themes,write_files"
optional_scopes = ["unauthenticated_read_product_listings", "unauthenticated_read_product_inventory"]
- Deployed the app to production
- App Bridge API is available and functioning (no JS errors)
Even after deployment, Shopify still returns the same
error when I try to request the same optional scopes. I double checked I’m sending the same scopes as in the ones in my TOML for the optional scopes.
The scopes I’m requesting match exactly what’s in my TOML file. I’m doing something like this for the request:
const shopify = useAppBridge();
await shopify.scopes.request(['unauthenticated_read_product_listings', 'unauthenticated_read_product_inventory']);
I have been trying for hours on my dev app and this keeps on failing. I have tried removing the flag and also setting it to false and waiting for a while.
Worth mentioning my app is quite old and was using use_legacy_install_flow=true for quite sometime. Also my app was previously non-embedded but now is an embedded app.
This is Shopify CLI version: @shopify/cli/3.53.0
and this is my AppBirdge version:
"@shopify/app-bridge-react": "^4.1.3"
Not sure what I’m doing wrong, could it be some sort of bug with the CLI?
Any help would be appreciated!