connected-car-python-sdk icon indicating copy to clipboard operation
connected-car-python-sdk copied to clipboard

Problem obtaining an Access Token for AU Client

Open danricho opened this issue 1 year ago • 2 comments

Describe the bug I don't appear to be getting a sufficient response as part of the .get_user_access_token() call.

Traceback (most recent call last):
  File "/sandpit/ford/test.py", line 4, in <module>
    access = client.get_user_access_token('<myusername>', '<mypw>')  # Fetch client access token
  File "/sandpit/ford/venv/lib/python3.9/site-packages/connectedcar/connectedcar.py", line 65, in get_user_access_token
    authURL = self.web_session(pkce_code)
  File "/sandpit/ford/venv/lib/python3.9/site-packages/connectedcar/connectedcar.py", line 120, in web_session
    authURL = re.findall('data-ibm-login-url="(.*)"\s', response.text)[0]
IndexError: list index out of range

I have also looked at what I'm getting in response.text and it appears to be a "problem" webpage... I suspect this is may be due to the fact that I'm in Australia. I've also confirmed both on the Ford Australia website and on the FordPass iOS app that my account isn't locked or anything like that.

To Reproduce - This is the script.

import connectedcar

client = connectedcar.AuthClient('9fb503e0-715b-47e8-adfd-ad4b7770f73b', None, None, None, 'AU')
access = client.get_user_access_token('<myusername>', '<mypw>')  # Fetch client access token
user = connectedcar.User(access['access_token'], 'AU') # New User Object

vehicles = user.vehicles()  # Fetch list of user vehicles

for userVehicle in vehicles:  # For each user vehicle
    vehicle = connectedcar.Vehicle(
        userVehicle['vin'], access['access_token'])  # Create vehicle object
    print(vehicle.details())  # Print vehicle details in json format

Expected behavior Successfully get an access token!

Desktop:

  • OS: Debian
  • Python 3.9.2

danricho avatar Feb 02 '24 09:02 danricho

For additional information, I've checked this for a few days now and the same HTML is returned. When I save it to a html file and Open it I get the following shown on the page:

Service is unavailable The service that you are trying to reach is temporarily unavailable. Our operations team is working to remediate this issue.

Try accessing the original page again in a few minutes.

danricho avatar Feb 05 '24 07:02 danricho

I get the same error from US. Using version 1.3.10. commands issued:

import connectedcar
client = connectedcar.AuthClient('9fb503e0-715b-47e8-adfd-ad4b7770f73b', None, None, None, 'US')
access = client.get_user_access_token('[email protected]', 'xxxxxxxx')

And reply is:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/app/fordpass/lib/python3.11/site-packages/connectedcar/connectedcar.py", line 65, in get_user_access_token
    authURL = self.web_session(pkce_code)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/fordpass/lib/python3.11/site-packages/connectedcar/connectedcar.py", line 120, in web_session
    authURL = re.findall('data-ibm-login-url="(.*)"\s', response.text)[0]
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

electropup42 avatar Feb 18 '24 21:02 electropup42