Skip to content

Instantly share code, notes, and snippets.

@phawk phawk/install.js
Created Aug 23, 2019

Embed
What would you like to do?
Shopify install lambda
exports.handler = async (event, context) => {
const shop = event.queryStringParameters.shop
const redirectUri = event.queryStringParameters.redirect
const apiKey = process.env.SHOPIFY_API_KEY
const scopes="read_content,write_content,read_products,read_themes,write_themes"
if (shop) {
const installUrl = 'https://' + shop +
'/admin/oauth/authorize?client_id=' + apiKey +
'&scope=' + scopes +
'&redirect_uri=' + redirectUri
return {
statusCode: 200,
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
redirectTo: installUrl
})
}
}
return {
statusCode: 400,
body: "Missing shop parameter. Please add ?shop=your-development-shop.myshopify.com to your request"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.