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

**URL:** <https://forum.shopware.com/t/how-to-connect-an-existing-customer-with-a-cart-created-with-sales-channel-api/61657>\
**Category:** Shopware Playground - API first Sandbox\
**Created:** [10. September 2019 um 08:26 UTC](https://forum.shopware.com/t/how-to-connect-an-existing-customer-with-a-cart-created-with-sales-channel-api/61657 "2019-09-10T08:26:22Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![SorinSologics2019](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@SorinSologics2019](https://forum.shopware.com/u/SorinSologics2019)\
**Post date:** [10. September 2019 um 09:34 UTC](https://forum.shopware.com/t/how-to-connect-an-existing-customer-with-a-cart-created-with-sales-channel-api/61657/3 "2019-09-10T09:34:16Z")

</div>

Hello Michael,

Thank you for your quick answer.

I’ve tried the following steps:

1. Create an empty cart&nbsp; 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&nbsp; **sw-context-token** and **sw-access-key&nbsp;** (POST /sales-channel-api/v1/checkout/cart/product/{productId})

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

{  
&nbsp; &nbsp; „errors“: [  
&nbsp; &nbsp; &nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; „status“: „401“,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; „code“: „CHECKOUT\_\_CUSTOMER\_AUTH\_BAD\_CREDENTIALS“,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; „title“: „Unauthorized“,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; „detail“: „Invalid username and/or password.“,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; „meta“: {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; „parameters“:   
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }  
&nbsp; &nbsp; &nbsp; &nbsp; }  
&nbsp; &nbsp; ]  
}

&nbsp;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

&nbsp;

---

_[View the full topic](https://forum.shopware.com/t/how-to-connect-an-existing-customer-with-a-cart-created-with-sales-channel-api/61657)._
