Re: How to create a customer with password in the graphql storefront API? Password field is not acce

Solved

How to create a customer with password in the graphql storefront API? Password field is not accepted

juanlet
Tourist
6 0 1

Hey, I want to create a customer with password using the graphql api. I followed the documentation to create a customer with password to avoid the activation process by email, this is the query I'm sending:

mutation  {
      customerCreate(
        input: {
          firstName: "dave",
          lastName: "smith",
          email: "[email protected]",
          password: "12345"
          acceptsMarketing: true,
          
            }
      ) {
        customer {
          id
          firstName
          lastName
          email
        }
        userErrors {
          field
          message
        }
        customer {
          id
          
        }
      }
    }

But I'm getting this error as if the specification changed:


{
  "errors": [
    {
      "message": "InputObject 'CustomerInput' doesn't accept argument 'password'",
      "locations": [
        {
          "line": 7,
          "column": 11
        }
      ],
      "path": [
        "mutation",
        "customerCreate",
        "input",
        "password"
      ],
      "extensions": {
        "code": "argumentNotAccepted",
        "name": "CustomerInput",
        "typeName": "InputObject",
        "argumentName": "password"
      }
    }
  ]
}

How do I do to achieve this? Thanks!

Accepted Solution (1)

Zameer
Shopify Staff
297 31 90

This is an accepted solution.

Hey there,

 

You might be seeing this error because your request is targeting the GraphQL Admin API and not the Storefront API. I would take a look at this guide which outlines the steps you need to follow.

 

Namely, you need to be using the proper GraphQL endpoint - `POST https://my-store-name.myshopify.com/api/graphql` and you need to provide the `X-Shopify-Storefront-Access-Token` header with your Storefront Access Token which is different from your Admin Access Token.

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 3 (3)

Zameer
Shopify Staff
297 31 90

This is an accepted solution.

Hey there,

 

You might be seeing this error because your request is targeting the GraphQL Admin API and not the Storefront API. I would take a look at this guide which outlines the steps you need to follow.

 

Namely, you need to be using the proper GraphQL endpoint - `POST https://my-store-name.myshopify.com/api/graphql` and you need to provide the `X-Shopify-Storefront-Access-Token` header with your Storefront Access Token which is different from your Admin Access Token.

To learn more visit the Shopify Help Center or the Community Blog.

juanlet
Tourist
6 0 1

Thanks!

nick-mealey
Shopify Partner
49 0 30

I realize this thread is a bit old and marked as "Solved", but it's worth mentioning that not supporting a password field from the Admin API is a real issue. It doesn't make sense that the only way you can create an account with a password is with the Storefront API. There are other fields (e.g. locale) in the Admin API that we require anyway, so we'd have to use a combination of both. It looks like for now we might have to use a combo of the REST and GraphQL Admin API.

Helium Development Shopify Developer, Website Design, App Development