karrioapi / karrio

Programmable Shipping API (self-hosted)
https://karrio.io
Apache License 2.0
506 stars 94 forks source link

UPS: Client ID Invalid #503

Closed MarcoWel closed 8 months ago

MarcoWel commented 8 months ago

Just updated from karrio 2023.5 to 2024.2.rc1. Getting the following error for UPS in production. Credentials are correct, it worked well before.

It seems this is due to UPS's new OAuth implementation which karrio is using now. Solution:

  1. Go to https://developer.ups.com/apps
  2. Choose "Add Apps" and request app access for shipping and tracking.
  3. Copy Cliend ID and Client Secret into the karrio UPS carrier settings.

image

Just wanted to document this here in case somebody else is stumbling over it.


"messages": [
    {
      "message": "ClientId is Invalid",
      "code": "10401",
      "carrier_name": "ups",
      "carrier_id": "UPS"
    }
  ],

Full log:

DEBUG helpers.py 244 sending request (9fb953e4-0415-4507-a4b4-3c983a91ca95)...
INFO helpers.py 184 Request URL:: https://onlinetools.ups.com/security/v1/oauth/token
ERROR helpers.py 217 HTTP Error 401: Unauthorized
DEBUG helpers.py 227 Error content:: HTTP Error 401: Unauthorized
ERROR interface.py 68 Invalid request payload
Traceback (most recent call last):
  File "/karrio/venv/lib/python3.11/site-packages/karrio/api/interface.py", line 66, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/karrio/venv/lib/python3.11/site-packages/karrio/api/interface.py", line 304, in process
    response: lib.Deserializable = gateway.proxy.get_rates(request)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/karrio/venv/lib/python3.11/site-packages/karrio/mappers/ups/proxy.py", line 35, in get_rates
    response = self._send_request(
               ^^^^^^^^^^^^^^^^^^^
  File "/karrio/venv/lib/python3.11/site-packages/karrio/mappers/ups/proxy.py", line 25, in _send_request
    "authorization": f"Bearer {self.settings.access_token}",
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^
danh91 commented 8 months ago

Hi @MarcoWel, Can you please share more about have this was resolved? Did you have to do anything in particular?

Thanks

MarcoWel commented 8 months ago

As documented in the issue under "Solution". Just needed to create the app in the UPS backend as described and it worked again.

danh91 commented 8 months ago

I realize I did read properly 😅 . Thanks for sharing it