cartBuyerIdentityUpdate mutation problem

Devtest1
New Member
1 0 0

Hey!
I'm trying to implement cart functionality currently, I've got a problem with singing valid customers to the newly created cart.
By this, I mean that I'm unable to add customerAccessToken to createCart mutation directly or cartBuyerIdentityUpdate mutation. With these two approaches, I'm getting the same error message:

 

{
  "data": {
    "cartBuyerIdentityUpdate": {
      "cart": null,
      "userErrors": [
        {
          "code": "INVALID",
          "field": [
            "buyerIdentity",
            "customerAccessToken"
          ],
          "message": "Customer is invalid"
        }
      ]
    }
  }
}

 

 My mutation for update looks like that:

 

mutation cartBuyerIdentityUpdate($cartId: ID!, $buyerIdentity: CartBuyerIdentityInput!) {
  cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {
    cart {
      id
      buyerIdentity {
        email
        phone
        countryCode
        customer {
          email
        }
      }
    }
    userErrors {
      code
      field
      message
    }
  }
}

variables to mutation: 
{
  "cartId": "Z2lkOi8vc2hvcGlmeS9DYXJ0L2FkOGRhMDNhMmQ5NzQ1N2YxYjJmZjhjY2QzZTgwYzY2",
  "buyerIdentity": {
    "customerAccessToken":"b95d5f29ed2250f13c76dc6fea711ee1"
   }
}

 

 both customer account and cart were created directly before calling this mutation.

All other fields passed with buyerIdentity work fine besides token.
Thanks for any help!

0 Likes
L_J_K
Shopify Staff
Shopify Staff
257 34 40

Hey @Devtest1 

Thanks for raising this! So, in short, applying the customer token seemed to work ok for me - I followed this flow calling the api/unstable/graphql.json Storefront API endpoint.

1. Created customer and used customerAccessTokenCreate to create customers access token

2. Called createCart and received my Cart ID

3. I copy pasted the mutation from your screenshot for CartBuyerIdentityUpdate and passed my cartId and customerAccessToken

4. I was able to successfully apply the CartBuyerIdentityUpdate mutation - I didn't receive the "customer is invalid" message myself.

I managed to received successful response when calling createCart too with this input :

{
  "cartInput": {
  "buyerIdentity": {
		"customerAccessToken": "customer_access_token"
	}
 }
}

The "INVALID" error(docs) points to an invalid input CustomerUserError  - I would check that the customer inputs are valid,  the customer Access Token is a valid one (not expired) and also that the correct access token is applied. Hope that helps!

 

| API Support @ Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
0 Likes