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 expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025