Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError on .authenticate response #4

Open
BillyCroan opened this issue May 1, 2021 · 2 comments
Open

KeyError on .authenticate response #4

BillyCroan opened this issue May 1, 2021 · 2 comments

Comments

@BillyCroan
Copy link

from prefect import FordAPI
f = FordAPI()
f.authenticate()
Traceback (most recent call last):
File "", line 1, in
File "/home/bcroan/.local/lib/python3.9/site-packages/prefect/init.py", line 291, in authenticate
self._token = res.json()["response"]["authToken"]
KeyError: 'response'
f.authenticate('myemailhere', 'mypwhere')
Traceback (most recent call last):
File "", line 1, in
File "/home/bcroan/.local/lib/python3.9/site-packages/prefect/init.py", line 291, in authenticate
self._token = res.json()["response"]["authToken"]
KeyError: 'response'

I made the config file and tried to use it first, no change when specifying pw directly.
Maybe services/webLoginPS no longer exists?

@j6k4m8
Copy link
Contributor

j6k4m8 commented May 2, 2021

Hey @BillyCroan! Thanks for reporting. I just played around with this a little bit and was able to get the same error when I used an invalid username form instead of my complete email address. Can you try it again with your complete email address? (Maybe that's what you already did — correct me if I'm mistaken!)

It might be helpful to verify that your login info works here: https://www.myfordmobile.com/content/mfm/app/site/login.html

If that doesn't help, drop a note and we'll start triage! In the meantime, this is definitely a lousy error message to get for an invalid login, so I'll improve the error message that we send back to users :)

@BillyCroan
Copy link
Author

BillyCroan commented May 2, 2021

I checked into the username. It wasn't truncated. But I do use caps.... It turns out it works when I lcase my email address in .config/myfordmobile.json. I registered with and log into the web interface of MyFordMobile with proper nouns in my email address capitalized. So I bet ford is lcasing it in their web based login process and I just didn't think to try that until now.

I've implemented my use case in bash with curl now btw. And also weirdly enough I didn't have any trouble logging in with CamelCase in my email address in my script (attached).

And perhaps also of note, while providing my email in the .json file all lower case does get .authenticate to succeed, I get another error when i try to enumerate vehicles:

>>> f.get_vehicles()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bcroan/.local/lib/python3.9/site-packages/prefect/__init__.py", line 316, in get_vehicles
    return [Vehicle.from_dict(r, self) for r in response]
  File "/home/bcroan/.local/lib/python3.9/site-packages/prefect/__init__.py", line 316, in <listcomp>
    return [Vehicle.from_dict(r, self) for r in response]
  File "/home/bcroan/.local/lib/python3.9/site-packages/prefect/__init__.py", line 52, in from_dict
    v._update_from_dict(data)
  File "/home/bcroan/.local/lib/python3.9/site-packages/prefect/__init__.py", line 61, in _update_from_dict
    self._dte = float(data.get("OVERALLDTE", 0))
TypeError: float() argument must be a string or a number, not 'dict'

So there might be a few todos:
more clear error message on failed auth
lcase the username on or around line 285 of PyMyFord/prefect/blob/master/prefect/init.py
looks like ford is sending back a different format than expected on get_vehicles (Or they're sending the single 4 digit error code responses that I've seen. I think like "6000"
getrange.txt
for auth error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants