Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi. I'm trying to create a delegate access token as documented here, but I'm getting 400 Bad Request errors.
Here's how I execute the call inside my auth/callback route (both shop and accessToken values are successfully retrieved):
const shop = req.query.shop
const {accessToken} = await Shopify.Utils.loadOfflineSession(shop)
fetch(`https://${shop}/admin/access_tokens/delegate.json`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Shopify-Access-Token': accessToken
},
body: JSON.stringify({
delegate_access_scope: 'read_products'
})
})
.then(result => console.log(result))
Side note: aside from the linked page, I can't find this documented anywhere in the REST Admin API reference. Am I looking in the wrong place?
In my code I am also facing the similar kind of problems while solving an error if I solve one then other error occurs so pleaseguide me why its not working for me?
It seems that delegate_access_scope expects a list of access_scopes, so you would need to change its value to ['read_products']
const shop = req.query.shop
const {accessToken} = await Shopify.Utils.loadOfflineSession(shop)
fetch(`https://${shop}/admin/access_tokens/delegate.json`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Shopify-Access-Token': accessToken
},
body: JSON.stringify({
delegate_access_scope: ['read_products']
})
})
.then(result => console.log(result))
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025