App reviews, troubleshooting, and recommendations
Hi all,
Following the official documentation, I've started an app which was put together with the standard Remix template.
Now I'm trying to access the current customer's cart and ID and I don't really understand how I'm supposed to authenticate.
So far I understood that:
Now I'm trying to make any GraphQL query at all on behalf of the customer and I systematically eat up a 403 with no explanation from the API.
Here is my code (sorry it's a bit messy but shows you what I'm attempting to do):
export const action = async ({ request }: ActionFunctionArgs) => { if (request.method !== "POST") { return json({ error: "Method not allowed" }, 400); } const schema = zod.object({ cart: zod.string(), }); const parsed = schema.safeParse(await request.json()); if (!parsed.success) { return json({ error: parsed.error }, 400); } const sf = await authenticate.public.appProxy(request); if (!sf.storefront) { return json({ error: "Could not authenticate" }, 400); } console.log(sf); // Retrieve the user's identity try { const identity = await sf.storefront.graphql( /* GraphQL */ ` query { customer(customerAccessToken: $accessToken) { id firstName lastName acceptsMarketing email phone } } `, { variables: { accessToken: sf.session.accessToken, }, } ); return json( { success: true, input: parsed.data, identity: await identity.json(), }, 200 ); } catch (error) { console.error("Error retrieving user identity:", error); return json({ error: "Failed to retrieve user identity" }, 500); } // const cart = await getCart({ // storefront: sf.storefront, // cartId: makeCartGid(parsed.data.cart), // }); // // return json({ success: true, input: parsed.data, cart }, 200); };
I'd be grateful for any pointers at this point!
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024