def log_out(access_token: str) -> bool: """ Revoke your access_token :param access_token: <str> :return: """ resource_path = '/oauth/access_token' api_client = ApiClient(access_token=access_token) api_client.call_api(resource_path=resource_path, method='DELETE') confirm(f"Successfully logged out.") return True
def send_text_otp(api_client: ApiClient, device_id: str, otp_secret: str) -> dict: resource_path = '/account/two-factor/token' header_params = { 'device-id': device_id, 'Content-Type': 'application/json', 'venmo-otp-secret': otp_secret } body = {"via": "sms"} response = api_client.call_api(resource_path=resource_path, header_params=header_params, body=body, method='POST') if response['status_code'] != 200: reason = None try: reason = response['body']['error']['message'] finally: raise AuthenticationFailedError( f"Failed to send the One-Time-Password to" f" your phone number because: {reason}") return response
def authenticate_using_otp(api_client: ApiClient, device_id: str, user_otp: str, otp_secret: str) -> str: resource_path = '/oauth/access_token' header_params = { 'device-id': device_id, 'venmo-otp': user_otp, 'venmo-otp-secret': otp_secret } params = {'client_id': 1} response = api_client.call_api(resource_path=resource_path, header_params=header_params, params=params, method='POST') return response['body']['access_token']
def authenticate_using_username_password(api_client: ApiClient, device_id: str, username: str, password: str) -> dict: resource_path = '/oauth/access_token' header_params = { 'device-id': device_id, 'Content-Type': 'application/json', 'Host': 'api.venmo.com' } body = { "phone_email_or_username": username, "client_id": "1", "password": password } return api_client.call_api(resource_path=resource_path, header_params=header_params, body=body, method='POST', ok_error_codes=[TWO_FACTOR_ERROR_CODE])
def log_out(access_token: str) -> bool: resource_path = '/oauth/access_token' api_client = ApiClient(access_token=access_token) api_client.call_api(resource_path=resource_path, method='DELETE') return True
def trust_this_device(api_client: ApiClient, device_id: str): header_params = {'device-id': device_id} resource_path = '/users/devices' api_client.call_api(resource_path=resource_path, header_params=header_params, method='POST')