invenhost / inventree-shopify

InvenTree plugin to link inventory with Shopify
MIT License
6 stars 1 forks source link

Received a naive datetime #8

Open medoix opened 1 year ago

medoix commented 1 year ago

I spent some time trying to understand why my API key was not working but i believe that error message [API] Invalid API key or access token (unrecognized login or wrong password) is not correct and is being sent after the failure to parse the date when attempting to create the webhook.

/root/.local/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1358: RuntimeWarning: DateTimeField NotificationEntry.updated received a naive datetime (2023-08-17 00:00:00) while time zone support is active.
  warnings.warn("DateTimeField %s.%s received a naive datetime "
Internal Server Error: /plugin/shopify/webhook/
Traceback (most recent call last):
  File "/root/.local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/root/.local/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.9/site-packages/inventree_shopify/ShopifyPlugin.py", line 173, in view_webhooks
    'webhooks': self._webhook_check(request.get_host())
  File "/usr/local/lib/python3.9/site-packages/inventree_shopify/ShopifyPlugin.py", line 206, in _webhook_check
    self._webhook_create(host, topic)
  File "/usr/local/lib/python3.9/site-packages/inventree_shopify/ShopifyPlugin.py", line 228, in _webhook_create
    raise KeyError(response)
KeyError: {'errors': '[API] Invalid API key or access token (unrecognized login or wrong password)'}
192.168.1.164 - - [18/Aug/2023:11:33:01 +0000] "GET /plugin/shopify/webhook/ HTTP/1.0" 500 18992 "http://192.168.1.10:3002/settings/"
medoix commented 1 year ago

So upon further investigation it appears that the webhooks are being created (i can see them in the Admin section as per screenshot). Once i deleted them all that Datetime error above disappeared but am still getting the Invalid API key or access token message when i know the credentials work (have tested them in another app)

image
matmair commented 1 year ago

@medoix the native datetime thingy is only a warning. The API key probably does not have the right for the APIs the plugin needs, especially if you are using them for another app. Webhooks in InvenTree and Shopify API access are not connected.

To debug this I need more info - it is working for me on a brand-new install. Please post your inventree version information, deployment method and at what step of the instructions you are stuck.

medoix commented 1 year ago

@matmair the custom app API key and shared secret has full permission access (everything selected).

InvenTree version: 0.12.13

Installed via docker using docker-compose and the files here https://github.com/inventree/InvenTree/tree/master/docker/production

I added the plugin to the polugins.txt file

# InvenTree Plugins (uses PIP framework to install)
inventree-shopify

I did raise a separate ticket because after the plugin was installed i was getting table errors so needed to manually run invoke update

The invoke migrations command returned the following (from the inventree-server container) but the update command appeared to work.

root@e2e263facb02:/home/inventree/InvenTree# invoke migrations
No idea what 'migrations' is!

I have added full scoped API credentials into the Admin

image

When i click on the button to test the Webhooks it appears a webhook is created but i get the error shared in the ticket above

image image
matmair commented 1 year ago

@medoix are you sure you have set api key (API key), Api password (admin-api token) and API shared secret (secret API key) correctly? I have repeated the setup on docker and can not find an error.

matmair commented 1 year ago

@medoix were you able to solve the problem by switching the keys?