Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi,
I try to create checkout via Storefront API but I have error:
{ "data": { "checkoutCreate": null }, "errors": [ { "message": "CheckoutCreate access denied", "locations": [ { "line": 2, "column": 11 } ], "path": [ "checkoutCreate" ] } ] }
And more details:
Request URI: https://domain.myshopify.com/api/2023-07/graphql.json
Request Body:
mutation { checkoutCreate( input: {buyerIdentity: {countryCode: US}, lineItems: [{variantId: "gid://shopify/ProductVariant/40128135659620", quantity: 1}], allowPartialAddresses: true, shippingAddress: {zip: "32-600", country: "PL", city: "Oświęcim", address1: "Dąbrowskiego"}} ) { checkout { id webUrl shippingAddress { zip } totalPrice { amount currencyCode } totalTax { amount currencyCode } shippingLine { title price { amount currencyCode } } availableShippingRates { ready shippingRates { price { currencyCode } } } } checkoutUserErrors { field message } } }
And curl request:
curl --location 'https://example.myshopify.com/api/2023-07/graphql.json' \ --header 'X-Shopify-Storefront-Access-Token: XYZ' \ --header 'Content-Type: application/json' \ --data '{"query":"mutation {\n checkoutCreate(\n input: {buyerIdentity: {countryCode: US}, lineItems: [{variantId: \"gid://shopify/ProductVariant/40128135659620\", quantity: 1}], allowPartialAddresses: true, shippingAddress: {zip: \"32-600\", country: \"PL\", city: \"Oświęcim\", address1: \"Dąbrowskiego\"}}\n ) {\n checkout {\n id\n webUrl\n shippingAddress {\n zip\n }\n totalPrice {\n amount\n currencyCode\n }\n totalTax {\n amount\n currencyCode\n }\n shippingLine {\n title\n price {\n amount\n currencyCode\n }\n }\n availableShippingRates {\n ready\n shippingRates {\n price {\n currencyCode\n }\n }\n }\n }\n checkoutUserErrors {\n field\n message\n }\n }\n }","variables":{}}'
For creating StorefrontAccessToken. And details of my token:
[access_token] => XYZ [access_scope] => unauthenticated_write_checkouts,unauthenticated_read_checkouts,unauthenticated_write_customers,unauthenticated_read_customers [created_at] => 2023-07-17T11:07:05+02:00 [id] => 61584998500 [admin_graphql_api_id] => gid://shopify/StorefrontAccessToken/61584998500 [title] => Token
Hi, is it possible to create custom checkout with this API?
i do not have to use the default shopify one?
Did you ever solve this?