-
When signing into my Venmo account using a GUI, I want to be able to trigger a popup that will allow me to enter the OTP code that is sent to my phone (if I'm signing in from a foreign device). Currently, I am only able to enter that code into the terminal. So, if the 2FA process is started while my program is running the function Client.get_access_token(), is there any way to trigger another function that will allow me to enter the OTP code into the GUI instead of the terminal? Thank you in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
As of now, you'd have to do the authentication manually for that. However, it will become more flexible if #35 gets completed or I'll add it later so that you can pass a function that is expected to return the OTP to the Here is a manual authentication template for you: def manually_login(username: str, password: str, device_id: str = None):
# You can use trusted device-id stored from before, pass it to AuthenticationApi(device_id="some id")
auth = AuthenticationApi(device_id=device_id)
response = auth.authenticate_using_username_password(username, password)
# this happens if you've used a trusted device-id
if not response.get('body').get('error'):
access_token = response['body']['access_token']
# return access_token and device_id used for auth
return access_token, auth.get_device_id()
# 2-factor-auth process
otp_secret = response['headers'].get('venmo-otp-secret')
if not otp_secret:
raise AuthenticationFailedError("Failed to get the otp-secret for the 2-factor authentication process. "
"(check your password)")
auth.send_text_otp(otp_secret=otp_secret)
#TODO: Update the user otp here, however you'd like to do so
user_otp = "The one-time-password that user receives on their phone (sms) goes here"
access_token = auth.authenticate_using_otp(user_otp, otp_secret)
# OPTIONAL
# if you want, you can add the random device-id generated to the list of trusted devices by doing the following
# Important: auth_api needs access_token you've received for trusting the device-id
auth.set_access_token(access_token=access_token)
# trusts the device-id used for authentication
auth.trust_this_device()
return access_token, auth.get_device_id() You can replace |
Beta Was this translation helpful? Give feedback.
As of now, you'd have to do the authentication manually for that. However, it will become more flexible if #35 gets completed or I'll add it later so that you can pass a function that is expected to return the OTP to the
Client.get_access_token()
function. In that case, you could make that passed function to read the input however you'd like.Here is a manual authentication template for you: