Closed zachary closed 3 years ago
Can you elaborate on "getting input from web"?
Thanks for updated, I mean the api wait 6 digital text code with python input('xxx'), how to change this to get 6 codes from web html
That's not possible as of now. However, I think it's a good idea to make the authentication process more flexible to be implemented differently. I'll make some changes this weekend, and let you know how you can do it.
Thanks for you updated.
I added new function as below, please advised it.
def __get_user_for_otp_password(self,username): otp = "" i=0 while len(otp) < 6 or not otp.isdigit(): if i>6: sys.exit('no') else: i=i+1 time.sleep(30) r = redis.Redis(host='localhost',port=6379,db=0) otp = r.get(username) return otp
On Tue, Sep 8, 2020 at 11:34 AM Mark Mohades notifications@github.com wrote:
That's not possible as of now. However, I think it's a good idea to make the authentication process more flexible to be implemented differently. I'll make some changes this weekend, and let you know how you can do it.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mmohades/Venmo/issues/12#issuecomment-689059993, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAWRT72DMRXLK7HS3PQTTLSEZ2LHANCNFSM4QQDIPLQ .
I added a function like this without @staticmethod
def __get_user_for_otp_password(self,username): otp = "" i=0 while len(otp) < 6 or not otp.isdigit(): if i>6: sys.exit('no') else: i=i+1 time.sleep(30) r = redis.Redis(host='localhost',port=6379,db=0) otp = r.get(username) return otp
I made the changes, but I haven't released a new version yet. After new version is released, you can do authentication manually. Here is an example of doing it manually:
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()
PLEASE make sure to handle token carefully. The access_token
NEVER gets expired, you have to revoke the token manually. You can do it by running: Client.log_out(token)
Also, if user changes their password, all the tokens will be expired.
I've released version 0.2.0 with the changes. Run pip3 install venmo-api --upgrade
to update to the new version.
def __ask_user_for_otp_password():
this function only get value from input(), but how to change to get this from web
thanks