Add Scopes component to request optional scopes from the frontend #1259
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
Closes: https://github.com/Shopify/develop-app-runtime-primitives/issues/390
WHAT is this pull request doing?
Creates a new OptionalScopesProvider react component to request optional scopes from the frontend to avoid server redirections
For now the component only supports
non embedded apps
. Once the app-bridge api to request optional scopes is available it will be integrated in this componentThe method signature to request optional scopes is:
scopes
- The list of scopes to requestonGrant
- The action to run in case the scopes are not granted and the user grants them (ie. update some UI)onAlreadyGranted
- The action to run in case the requested scopes are already granted (ie. create a product)How the component works
onGrant
action is executed if the user has confirmed the scopesRequirements
ScopesInformation
using thescopes.query
apiscopes.request
api. Thescopes
are sent as a query param{APP_URL}/auth/scopes/query
{APP_URL}/auth/scopes/request?scopes=
/auth/scopes
and the subpathsquery
andrequest
are configurable through theAppProvider
Modifications in the sample Remix app created to 🎩 the library:
non embedded
Products maker
section requiresread_products
using server side redirectionwrite_products
and will use the new component to request itTophat 🎩
1. Setup using a non embedded app
shopify-app-js
librarylink
your local app with a new remote appapp_access_optional_scopes
for the new remote apptoml
to include the followingscopes
configuration:deploy
a new app versiondev
command and preview the app2. Granting the scope to create products
Products maker
section and grant theread_products
scope when it's requiredDemo video
Type of change
Checklist
yarn changeset
to create a draft changelog entry (do NOT update theCHANGELOG.md
files manually)