I’ve made progress (I think) with getting delegate access scope working on my custom app for my store. However, I keep getting this error:
Error: GraphQL Error (Code: 422):
{"response":{"errors":{"delegate_access_scope":["The access scope
can’t be empty."]},
To simply get this working I’m using the example from the docs:
const accessToken = gql`mutation {
delegateAccessTokenCreate(input: { delegateAccessScope: ["write_orders" ], expiresIn: 3600 }){
delegateAccessToken {
accessToken
}
shop {
id
}
userErrors {
field
message
}
}
}`
I’m kind of at my wits end here as I finally realized that the delegate.json actually needs the ADMIN key rather than the storefront even though I want to use this with the storefront API (which is weird). All I want to be able to do is create a new customer with a password via this API.
Thanks in advance.
2
Answers
Ok, so I figured it out. I don't actually want a delegateAccessToken to create a user but to have a Storefront API Access Token. This may get a bit confusing but you use your Admin Access Token to request a storefront access token like so (I use graphql-request on npm):
From here you now have a Storefront Access Token and can make a call via Oauth to create a customer like so:
This will now create the user using the Storefront API.
Maybe you just need to change delegateAccessScope: to delegate_access_scope per doc, https://shopify.dev/apps/auth/oauth/delegate-access-tokens/create
{
"delegate_access_scope": [
"write_orders"
],
"expires_in": 3600
}