scottmconway / shopgoodwill-scripts

A collection of scripts for programmatically interacting with Shopgoodwill
GNU General Public License v3.0
51 stars 17 forks source link

exception=AttributeError("'list' object has no attribute 'items'")> #22

Closed derzahla closed 10 months ago

derzahla commented 10 months ago

Hi, I would like to get this working. I created a venv, installed requirements.txt, and also had to install pycryptodomex to satisfy dependencies. Next I copied config.json.sample to config.json, set 'username' and 'password' under auth_type to my plain text username and pw. Launching bid_sniper.py returned the error below. Since it appears to be expecting items to be 'favorited' I added a few items to my favorite list on shopgoodwill.com but the error still persists. Please advise. Thanks!

ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-1' coro=<BidSniper.main_loop() done, defined at /home/user/apps/shopgoodwill-scripts/./bid_sniper.py:380> exception=AttributeError("'list' object has no attribute 'items'")>
Traceback (most recent call last):
  File "/home/user/apps/shopgoodwill-scripts/./bid_sniper.py", line 398, in main_loop
    for item_id, favorite_info in self.favorites_cache["favorites"].items():
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'items'

Trying to use "./schedule_bid.py " I get the following error:

  File "/home/user/apps/shopgoodwill-scripts/venv/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://buyerapi.shopgoodwill.com/api/Favorite/AddToFavorite?itemId=188303280

I have also tried removing my username and password from config.json and adding my bearer token from my browser session, same results.

Im using Python 3.11.6

derzahla commented 10 months ago

Ok, as a last attempt i dug out my encrypted username and password and used that. Now it seemingly works!

scottmconway commented 10 months ago

Thanks for the catch with pycryptodomex. The project indeed requires that library.

It looks like the ShopGoodwill object's init was happy with your config, since it didn't raise an exception.

https://github.com/scottmconway/shopgoodwill-scripts/blob/main/shopgoodwill.py#L89

SGW could've changed their encryption key / method, but I can confirm that this is not the case, as plaintext login continues to work for me.

There must be something wrong with the way your installation is calling the encryption function (or there was a typo in your credentials). I can't seem to replicate this on my installation, so please let me know if you'd be interested in troubleshooting this! You should absolutely be able to use plaintext login.

scottmconway commented 10 months ago

Also just for clarification - bid_sniper isn't expecting any items to be favorited, and will run fine (but do nothing) without any favorites.