Tib612 / pluxee-api

A python API to access Pluxee (Sodexo) balance and transactions
https://pypi.org/project/pluxee-api/
MIT License
9 stars 1 forks source link

Sodexo4you login url starts redirecting to Pluxee.be #3

Open jessedobbelaere opened 2 months ago

jessedobbelaere commented 2 months ago

I'm trying to set up the Home Assistant card for Pluxee, but it fails with a 301 status code using the 0.2.1 release of this API.

The reason is that the https://sodex4you/fr/frontpage URL used to login, sends a 301 with a redirect header to https://users.pluxee.be/fr/frontpage?destination=%2Ffr%2Ffrontpage

Snippet to test:

from pluxee import PluxeeClient

username = input("Username: (leave empty to use PLUXEE_USERNAME env variable)")
password = input("password: (leave empty to use PLUXEE_PASSWORD env variable)")

pc = PluxeeClient(username, password)

balance = pc.get_balance()
print(balance)

Response:

imported aia 0.2.0
Username: (leave empty to use PLUXEE_USERNAME env variable)
password: (leave empty to use PLUXEE_PASSWORD env variable)
creating AIASession
cadata_and_host_regex_from_host www.sodexo4you.be
cadata_and_host_regex_from_host cache miss
Downloading TLS certificate chain from https://www.sodexo4you.be
fetching missing issuer cert for cert <X509Name object '/C=BE/ST=Brussels Hoofdstedelijk Gewest/O=Pluxee Belgium/CN=www.users.pluxee.be'>
aia_ca_issuers ['http://crt.sectigo.com/SectigoRSAOrganizationValidationSecureServerCA.crt']
Downloading CA issuer certificate from http://crt.sectigo.com/SectigoRSAOrganizationValidationSecureServerCA.crt
issuer_cert subject <X509Name object '/C=GB/ST=Greater Manchester/L=Salford/O=Sectigo Limited/CN=Sectigo RSA Organization Validation Secure Server CA'>
Traceback (most recent call last):
  File "/Users/jesse.dobbelaere/Downloads/test-pluxee/main.py", line 8, in <module>
    balance = pc.get_balance()
              ^^^^^^^^^^^^^^^^
  File "/Users/jesse.dobbelaere/Downloads/test-pluxee/.venv/lib/python3.12/site-packages/pluxee/pluxee_client.py", line 84, in get_balance
    response = self._make_request(self.BASE_URL_LOCALIZED, {"check_logged_in": "1"}, session)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jesse.dobbelaere/Downloads/test-pluxee/.venv/lib/python3.12/site-packages/pluxee/pluxee_client.py", line 47, in _make_request
    self._login(session)
  File "/Users/jesse.dobbelaere/Downloads/test-pluxee/.venv/lib/python3.12/site-packages/pluxee/pluxee_client.py", line 32, in _login
    self.handle_login_status(response.status_code)
  File "/Users/jesse.dobbelaere/Downloads/test-pluxee/.venv/lib/python3.12/site-packages/pluxee/base_pluxee_client.py", line 184, in handle_login_status
    raise PluxeeAPIError(f"Pluxee webpage did not respond with the expected status. {status}")
pluxee.exceptions.PluxeeAPIError: Pluxee webpage did not respond with the expected status. 301
Tib612 commented 1 month ago

Hi,

Thanks for reporting this. It indeed seems they have change the API again. I'll have a look when I have some time. But as pluxee has a more comlpex login, I'm not sure I will be able to make it work.

semiBE commented 3 weeks ago

Hi Thibaut,

I am trying to integrate the pluxee API with firefly_iii and I am looking forward to this! Thanks!