Hello everyone,
I have been trying to develop a way to login my users in my within the Storefront API.
I currently have an Express + Firebase functions that act as my backend.
So far I have created a test shop and installed the headless channel and I have been able to do a request using Postman to retrieve some products.
My current code:
const unrestrictedHeaders = {
'Content-Type': 'application/graphql',
'X-Shopify-Storefront-Access-Token': shopifyStoreFrontAPIUnrestricted
};
router.post('/create-token', async (req, res) => {
const query = `mutation {
customerAccessTokenCreate({"input": {"email": "${req.body.email}", "password": "${req.body.password}"}}) {
customerAccessToken {
accessToken
}
customerUserErrors {
message
}
}
}`;
try {
const response = await axios.post(shopifyEndPoint, { query }, { unrestrictedHeaders });
res.send(response.data);
} catch (error) {
console.error(error);
res.status(500).send(error.message);
}
});
Any help pointing the right direction would be awesome. Also it would be great to have a code repository with examples as I haven’t been able to locate a proper one with full code examples.
Best,
Stockers