How to connect an existing customer with a cart created with sales channel API?

Hello Michael,

Thank you for your quick answer.

I’ve tried the following steps:

  1. Create an empty cart  by passing the SW-Access-Key taken from API access key(Sales Channel) -> get the sw-context-token (POST / sales-channel-api/v1/checkout/cart)

  2. Get the cart by passing sw-context-token and sw-access-key -> get empty cart (GET /sales-channel-api/v1/checkout/cart)

  3. Add a product to the cart by passing  sw-context-token and sw-access-key  (POST /sales-channel-api/v1/checkout/cart/product/{productId})

  4. Try to login an existing shop customer by passing username, passwordsw-context-token and sw-access-key  (POST /sales-channel-api/v1/customer/login).  Here I get this error even if the credentials are ok and I’m able to login with them in storefront:

{
    „errors“: [
        {
            „status“: „401“,
            „code“: „CHECKOUT__CUSTOMER_AUTH_BAD_CREDENTIALS“,
            „title“: „Unauthorized“,
            „detail“: „Invalid username and/or password.“,
            „meta“: {
                „parameters“:
            }
        }
    ]
}

 I forgott to specify that we are using a shop channel and not a headless channel.

Is it necessary that the customer should be created with sales channel API in order to be logged in or should it work even if the customer is created from admin area?

I’m not sure what I’m doing wrong.

Best regards,

Sorin