401 Error on Each Request

ob1ob1 Member Posts: 5
edited March 2019 in Development

We're no longer able to get a successful response from the API. It appears it now just returns the 401 error on any call we make. The code hasn't changed from our side so i'm unsure why it would just stop.


  • [Deleted User][Deleted User] Posts: 0

    Hello @ob1,

    The error message 401 in most of the occasions indicates that the username/password is not correct, it's quite possible that the password used by the integration has expired, please test the credentials login into Lightspeed

  • ob1ob1 Member Posts: 5

    Ok that's most likely our issue. We've created a new user and now get the 403 error on all calls.

  • ob1ob1 Member Posts: 5

    Is there a reason we would now be getting 403 errors?

  • [Deleted User][Deleted User] Posts: 0

    Hi @ob1 ,

    Would you please send us a copy of the api call and payload used along with the error message?

  • ob1ob1 Member Posts: 5

    Hi Alex,

    Apologies for the huge delay on coming back to you on this.

    Error Message:

    2019-05-22 13:36:18,343: commencing requests

    2019-05-22 13:36:18,349: Starting new HTTPS connection (1): localhost:9630

    2019-05-22 13:36:18,539: https://localhost:9630 "GET /api/products/?count=1000&offset=0 HTTP/1.1" 403 295

    2019-05-22 13:36:18,540: status code is 403

    Traceback (most recent call last):

     File "working.py", line 34, in <module>

      assert get_response.status_code == 200



    # Setup a session for the http request.

    session = requests.Session()



      'user-agent': '{}/{}'.format(APP_ID, APP_VERSION),

      'x-pappid': APP_PRIVATE_ID


    session.verify = False

    session.stream = True

    output_xml = ET.Element('products')

    products_seen = 0

    logging.info('commencing requests')

    for offset in count(0, PRODUCTS_PER_REQUEST):

      get_response = session.get(PRODUCTS_URL, params={'count': 5, 'offset': offset})

      logging.info('status code is {}'.format(get_response.status_code))

      assert get_response.status_code == 200

      response_xml = ET.fromstring(get_response.text)

      products = response_xml.findall('product')

      if not products:


      num_products = len(products)

      products_seen += num_products

      logging.info('seen {} in batch and {} in total'.format(num_products, products_seen))


    # Log out.

    logout_response = session.post(LOGOUT_URL)

    assert logout_response.status_code == 204

    logging.info('logging out succeeded')

Sign In or Register to comment.