diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0b81a20
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/venv
+__pycache__
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index df9461d..c85e706 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2020 Bandwidth Samples
+Copyright (c) 2022 Bandwidth Samples
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 634cbab..9662f9d 100644
--- a/README.md
+++ b/README.md
@@ -1,48 +1,53 @@
-# 2FA CLI Python
-
-
+# Multi-Factor Auth CLI
+
+
+
+
# Table of Contents
-
+* [Description](#description)
+* [Pre-Requisites](#pre-requisites)
+* [Running the Application](#running-the-application)
+* [Environmental Variables](#environmental-variables)
-- [2FA CLI Python](#2fa-cli-python)
-- [Description](#description)
-- [Bandwidth](#bandwidth)
-- [Environmental Variables](#environmental-variables)
-- [Development Environment Setup](#development-environment-setup)
-- [Run The App](#run-the-app)
+# Description
-
+This app allows you to enter your phone number in E164 format to receive a multi-factor auth code either by voice or sms. After entering your phone number and selecting the mfa method, you will receive a text message or phone call with your authentication code. Entering this code in the final prompt will allow you to verify the code. Note that you will need separate applications for voice and messaging depending on which method you would like to use. More information about the application setup can be found in the [Pre-Requisites](#pre-requisites) section.
-# Description
-A small CLI sample app that creates a 2FA code request, and a 2FA code validation request via Bandwidth's 2FA API
+This app also demonstrates basic API Error handling. By entering an invalid code (e.g. 1), you will receive a `400 Bad Request` from the API, which is handled by the `except` statement at the end of the app.
-# Bandwidth
+# Pre-Requisites
-In order to use the Bandwidth 2FA API, users need to have their applications setup. Please reach out to your account manager to set this up.
+In order to use the Bandwidth API users need to set up the appropriate application at the [Bandwidth Dashboard](https://dashboard.bandwidth.com/) and create API tokens.
-For more information about API credentials see [here](https://dev.bandwidth.com/guides/accountCredentials.html#top)
+To create an application log into the [Bandwidth Dashboard](https://dashboard.bandwidth.com/) and navigate to the `Applications` tab. Fill out the **New Application** form selecting the service (Messaging or Voice) that the application will be used for.
-# Environmental Variables
-The sample app uses the below environmental variables.
-```sh
-BW_ACCOUNT_ID # Your Bandwidth Account Id
-BW_USERNAME # Your Bandwidth API Token
-BW_PASSWORD # Your Bandwidth API Secret
-BW_NUMBER # Your The Bandwidth Phone Number
-BW_VOICE_APPLICATION_ID # Your Voice Application Id created in the dashboard
-BW_MESSAGING_APPLICATION_ID # Your Messaging Application Id created in the dashboard
-```
+For more information about API credentials see our [Account Credentials](https://dev.bandwidth.com/docs/account/credentials) page.
-# Development Environment Setup
+# Running the Application
-```
+To install the required packages for this app, run the command:
+
+```sh
pip install -r requirements.txt
```
-# Run The App
+Use the following command to run the application:
+```sh
+python main.py
```
-python app.py
+
+# Environmental Variables
+
+The sample app uses the below environmental variables.
+
+```sh
+BW_ACCOUNT_ID # Your Bandwidth Account Id
+BW_USERNAME # Your Bandwidth API Username
+BW_PASSWORD # Your Bandwidth API Password
+BW_NUMBER # The Bandwidth phone number involved with this application
+BW_VOICE_APPLICATION_ID # Your Voice Application Id created in the dashboard
+BW_MESSAGING_APPLICATION_ID # Your Messaging Application Id created in the dashboard
```
diff --git a/app.py b/app.py
deleted file mode 100644
index 6df42e5..0000000
--- a/app.py
+++ /dev/null
@@ -1,95 +0,0 @@
-"""
-app.py
-
-2FA CLI sample app using Bandwidth's 2FA API
-"""
-from bandwidth.bandwidth_client import BandwidthClient
-from bandwidth.twofactorauth.models.two_factor_code_request_schema import TwoFactorCodeRequestSchema
-from bandwidth.twofactorauth.models.two_factor_verify_request_schema import TwoFactorVerifyRequestSchema
-
-import os
-
-try:
- BW_USERNAME = os.environ['BW_USERNAME']
- BW_PASSWORD = os.environ['BW_PASSWORD']
- BW_ACCOUNT_ID = os.environ['BW_ACCOUNT_ID']
- BW_NUMBER = os.environ['BW_NUMBER']
- BW_VOICE_APPLICATION_ID = os.environ['BW_VOICE_APPLICATION_ID']
- BW_MESSAGING_APPLICATION_ID = os.environ['BW_MESSAGING_APPLICATION_ID']
-except:
- print("Please set the environmental variables defined in the README")
- exit()
-
-bandwidth_client = BandwidthClient(
- two_factor_auth_basic_auth_user_name=BW_USERNAME,
- two_factor_auth_basic_auth_password=BW_PASSWORD
-)
-auth_client = bandwidth_client.two_factor_auth_client.mfa
-
-recipient_phone_number = input("Please enter your phone number in E164 format (+15554443333): ")
-delivery_method = input("Select your method to receive your 2FA request. Please enter \"voice\" or \"messaging\": ")
-
-if delivery_method == "messaging":
- from_phone = BW_NUMBER
- to_phone = recipient_phone_number
- application_id = BW_MESSAGING_APPLICATION_ID
- scope = "scope"
- digits = 6
-
- body = TwoFactorCodeRequestSchema(
- mfrom = from_phone,
- to = to_phone,
- application_id = application_id,
- scope = scope,
- digits = digits,
- message = "Your temporary {NAME} {SCOPE} code is {CODE}"
- )
- auth_client.create_messaging_two_factor(BW_ACCOUNT_ID, body)
-
- code = input("Please enter your received code: ")
-
- body = TwoFactorVerifyRequestSchema(
- to = to_phone,
- application_id = application_id,
- scope = scope,
- code = code,
- expiration_time_in_minutes = 3
- )
- response = auth_client.create_verify_two_factor(BW_ACCOUNT_ID, body)
-
- if response.body.valid:
- print("Success!")
- else:
- print("Failure")
-else:
- from_phone = BW_NUMBER
- to_phone = recipient_phone_number
- application_id = BW_VOICE_APPLICATION_ID
- scope = "scope"
- digits = 6
-
- body = TwoFactorCodeRequestSchema(
- mfrom = from_phone,
- to = to_phone,
- application_id = application_id,
- scope = scope,
- digits = digits,
- message = "Your temporary {NAME} {SCOPE} code is {CODE}"
- )
- auth_client.create_voice_two_factor(BW_ACCOUNT_ID, body)
-
- code = input("Please enter your received code: ")
-
- body = TwoFactorVerifyRequestSchema(
- to = to_phone,
- application_id = application_id,
- scope = scope,
- code = code,
- expiration_time_in_minutes = 3
- )
- response = auth_client.create_verify_two_factor(BW_ACCOUNT_ID, body)
-
- if response.body.valid:
- print("Success!")
- else:
- print("Failure")
diff --git a/icon-mfa.svg b/icon-mfa.svg
new file mode 100644
index 0000000..fca45c4
--- /dev/null
+++ b/icon-mfa.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/main.py b/main.py
new file mode 100644
index 0000000..300a49e
--- /dev/null
+++ b/main.py
@@ -0,0 +1,100 @@
+import os
+import re
+
+# TODO: Needs to be changed when the SDK becomes python package.
+import sys
+sys.path.insert(0, 'C:/Users/ckoegel/Documents/sdks/bandwidth_python')
+import bandwidth_python
+from bandwidth_python.api.mfa_api import MFAApi
+from bandwidth_python.model.two_factor_code_request_schema import TwoFactorCodeRequestSchema
+from bandwidth_python.model.two_factor_verify_request_schema import TwoFactorVerifyRequestSchema
+from bandwidth_python.exceptions import ApiException
+# ---------------------------------------------------
+
+
+BW_ACCOUNT_ID = os.environ.get('BW_ACCOUNT_ID')
+BW_USERNAME = os.environ.get('BW_USERNAME')
+BW_PASSWORD = os.environ.get('BW_PASSWORD')
+BW_NUMBER = os.environ.get('BW_NUMBER')
+BW_VOICE_APPLICATION_ID = os.environ.get('BW_VOICE_APPLICATION_ID')
+BW_MESSAGING_APPLICATION_ID = os.environ.get('BW_MESSAGING_APPLICATION_ID')
+
+
+configuration = bandwidth_python.Configuration( # TODO: # Configure HTTP basic authorization: httpBasic
+ username=BW_USERNAME,
+ password=BW_PASSWORD
+)
+
+
+api_client = bandwidth_python.ApiClient(configuration) # TODO: package name
+mfa_api_instance = MFAApi(api_client) # TODO: package name
+
+recipient_phone_number = input("\nPlease enter your phone number in E164 format (+19195551234): ")
+while True:
+ if re.match(r"^\+[1-9]\d{4,14}$", recipient_phone_number):
+ break
+ else:
+ recipient_phone_number = input("Invalid phone number. Please enter your phone number in E164 format (+19195551234): ")
+
+
+
+delivery_method = input("\nPlease select your MFA method.\nEnter 0 for voice or 1 for messaging: ")
+while True:
+ if re.match(r"^[0-1]$", delivery_method):
+ break
+ else:
+ delivery_method = input("Invalid selection. Enter 0 for voice or 1 for messaging: ")
+
+
+if bool(int(delivery_method)):
+
+ body = TwoFactorCodeRequestSchema(
+ _from = BW_NUMBER,
+ to = recipient_phone_number,
+ application_id = BW_MESSAGING_APPLICATION_ID,
+ scope = "scope",
+ digits = 6.0,
+ message = "Your temporary {NAME} {SCOPE} code is {CODE}"
+ )
+ mfa_api_instance.messaging_two_factor(BW_ACCOUNT_ID, body)
+
+ code = input("\nPlease enter your received code: ")
+
+ body = TwoFactorVerifyRequestSchema(
+ to = recipient_phone_number,
+ application_id = BW_MESSAGING_APPLICATION_ID,
+ scope = "scope",
+ code = code,
+ expiration_time_in_minutes = 3.0
+ )
+else:
+ body = TwoFactorCodeRequestSchema(
+ _from = BW_NUMBER,
+ to = recipient_phone_number,
+ application_id = BW_VOICE_APPLICATION_ID,
+ scope = "scope",
+ digits = 6.0,
+ message = "Your temporary {NAME} {SCOPE} code is {CODE}"
+ )
+ mfa_api_instance.voice_two_factor(BW_ACCOUNT_ID, body)
+
+ code = input("\nPlease enter your received code: ")
+
+ body = TwoFactorVerifyRequestSchema(
+ to = recipient_phone_number,
+ application_id = BW_VOICE_APPLICATION_ID,
+ scope = "scope",
+ code = code,
+ expiration_time_in_minutes = 3.0
+ )
+
+try:
+ response = mfa_api_instance.verify_two_factor(BW_ACCOUNT_ID, body)
+
+ if response.valid:
+ print("Success!")
+ else:
+ print("Incorrect Code")
+
+except ApiException as e:
+ print(e)