tdorssers / TeslaPy

A Python module to use the Tesla Motors Owner API
MIT License
374 stars 83 forks source link

Authentication error - ValueError: `passcode_getter` callback is not set #7

Closed j450h1 closed 3 years ago

j450h1 commented 3 years ago
import teslapy
with teslapy.Tesla('{my_email}, '{my_password}') as tesla:
        tesla.fetch_token()
        vehicles = tesla.vehicle_list()
        print(vehicles)

Traceback (most recent call last): File "", line 2, in File "/Users/jas/github/TeslaPy/teslapy/teslapy.py", line 139, in fetch_token response = self._check_mfa(oauth, transaction_id) File "/Users/jas/github/TeslaPy/teslapy/teslapy.py", line 158, in _check_mfa raise ValueError('passcode_getter callback is not set') ValueError: passcode_getter callback is not set

j450h1 commented 3 years ago

Is MFA mandatory?

j450h1 commented 3 years ago

Looks like I forgot that I had MFA enabled. I opened up Google Authenticator and quickly got the code before it disappeared and now this is working like a charm!

with teslapy.Tesla('{my_email}, '{my_password}', lambda: '{MFA_CODE_FROM_AUTHENTICATOR_APP}') as tesla:
    tesla.fetch_token()
    vehicles = tesla.vehicle_list()
    print(vehicles)