ianjwhite99 / connected-car-python-sdk

Open-source Python SDK for Ford vehicles connected with Sync Connect (Ford Pass)
MIT License
73 stars 12 forks source link

Problem obtaining an Access Token for AU Client #83

Open danricho opened 8 months ago

danricho commented 8 months ago

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:

danricho commented 8 months ago

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.

electropup42 commented 7 months ago

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('xxx@yyy.zzz', '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