Skip to content

Commit

Permalink
Merge pull request #408 from rooniks/personal_kvdb_bucket
Browse files Browse the repository at this point in the history
Personal KVDB buckets [To solve: error fetching OTP API:Not Found]
  • Loading branch information
bombardier-gif authored Jun 2, 2021
2 parents 3f00af8 + 9af2de7 commit f0984b2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@

<br>

## KVDB setup
Regardless of Android or iOS, you will need a KVDB bucket configured to act as a key value store for your OTP messages coming from the IFTTT app or CoWIN OTP Retriever. You will need to update your personal key every 14 days or buy a pro account on kvdb.
Steps to get your own KVDB bucket:

1. Go to https://kvdb.io/
2. Click on Get started now
3. Enter your email and click on Create bucket
4. You will get a bucket key. It is just a random sequence of characters eg. ASth4wnvVDPkg2bdjsiqMN
5. Keep this key saved somewhere in your notes. We will need it.

## Setup Guide for Android

### Option 1: IFTTT
Expand All @@ -93,7 +103,7 @@
3. If this..... click on Android SMS trigger
4. Select "New SMS received matches search" and use CoWIN as the search key
5. Then... Choose a service named Webhooks and then select make a web request
6. Paste the url: https://kvdb.io/ASth4wnvVDPkg2bdjsiqMN/99XXXXXXXX replace 99XXXXXXXX with your phone number
6. Paste the url: https://kvdb.io/<kvdb_bucket>/99XXXXXXXX replace 99XXXXXXXX with your phone number and <kvdb_bucket> with your own key that you got in the previous step of KVDB setup.
7. Method is PUT
8. Content Type PlainText
9. Body: Add ingredient and select Text
Expand Down Expand Up @@ -134,7 +144,7 @@
2. Follow this guide to install apps from unknown sources: https://www.verizon.com/support/knowledge-base-222186/
3. Allow the app to run in background so that the app does not stop even if you multi-task or leave the phone idle. (Note that, there still might be some phone model specific settings and optimizations which could stop the app from running in background. Check point number 8)
4. Grant sms access to allow the app to read CoWIN OTP sms.
5. Enter 10 digit mobile number registered on the CoWIN portal.
5. Enter 10 digit mobile number registered on the CoWIN portal. Also enter your personal KVDB bucket value.
6. Switch ON the OTP Listener.
7. If the OTP is successfully sent to the key value store, you will see the status as shown below.
8. Ensure that the battery saver mode, and all other optimizations are removed. The app should always run (This is the key for quick response).
Expand All @@ -160,7 +170,7 @@
3. Select the `Message` option
4. Put `CoWIN` in the Message Contains option & leave everything blank. Tap on Next button
5. Tap on `Add action` and search for the option `Set Variable`. Give the variable name `text` and input as `Shortcut Input`
6. Then add another action and select `URL` and paste the url: https://kvdb.io/ASth4wnvVDPkg2bdjsiqMN/99XXXXXXXX replace 99XXXXXXXX with your phone number
6. Then add another action and select `URL` and paste the url: https://kvdb.io/<kvdb_bucket>/99XXXXXXXX replace 99XXXXXXXX with your phone number and <kvdb_bucket> with your bucket value from the KVDB setup step
7. Then add another action and select `Get Contents of Url`. Click on show more. Change the method to `PUT`. Request Body to `File` and in the file row tap on `Choose Variable` and select `text` which we defined in Step 6.
8. Click Next and save this automation.
9. Clone this repository
Expand Down
9 changes: 7 additions & 2 deletions src/covid-vaccine-slot-booking.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,15 @@ def main():
filename = filename + mobile + ".json"
otp_pref = input("\nDo you want to enter OTP manually, instead of auto-read? \nRemember selecting n would require some setup described in README (y/n Default n): ") if args.no_tty else "n"
otp_pref = otp_pref if otp_pref else "n"
kvdb_bucket = input("Please refer KVDB setup in ReadMe to setup your own KVDB bucket. Please enter your KVDB bucket value here: ")
if not kvdb_bucket:
print("Sorry, having your private KVDB bucket is mandatory. Please refer ReadMe and create your own private KVBD bucket.")
sys.exit()
print("\n### Note ### Please make sure the URL configured in the IFTTT/Shortcuts app on your phone is: " + "https://kvdb.io/" + kvdb_bucket + "/" + mobile + "\n")
while token is None:
if otp_pref=="n":
try:
token = generate_token_OTP(mobile, base_request_header)
token = generate_token_OTP(mobile, base_request_header, kvdb_bucket)
except Exception as e:
print(str(e))
print('OTP Retrying in 5 seconds')
Expand Down Expand Up @@ -148,7 +153,7 @@ def main():
while token is None:
if otp_pref=="n":
try:
token = generate_token_OTP(mobile, base_request_header)
token = generate_token_OTP(mobile, base_request_header, kvdb_bucket)
except Exception as e:
print(str(e))
print('OTP Retrying in 5 seconds')
Expand Down
3 changes: 1 addition & 2 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@ def book_appointment(request_header, details, mobile, generate_captcha_pref):
" Hey, Hey, Hey! It's your lucky day! "
)
print("\nPress any key thrice to exit program.")
requests.put("https://kvdb.io/" + kvdb_bucket + "/" + str(uuid.uuid4()), data={})
os.system("pause")
os.system("pause")
os.system("pause")
Expand Down Expand Up @@ -1044,7 +1043,7 @@ def clear_bucket_and_send_OTP(storage_url, mobile, request_header):
return txnId


def generate_token_OTP(mobile, request_header):
def generate_token_OTP(mobile, request_header, kvdb_bucket):
"""
This function generate OTP and returns a new token or None when not able to get token
"""
Expand Down

0 comments on commit f0984b2

Please sign in to comment.