From 6aa5425f45e70df894a74ca297b9af53b7c5559d Mon Sep 17 00:00:00 2001 From: JB Date: Wed, 16 Nov 2022 12:06:11 -0600 Subject: [PATCH] Adding Branch for testing --- getAuth.py | 49 +++++++++++++++++ guiTesting.py | 44 ++++++++++++++++ header_data.py | 6 +++ json_data.py | 24 +++++++++ main.py | 31 ++++++++++- stationList.txt | 44 ++++++++++++++++ stationlist.py | 136 ++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 332 insertions(+), 2 deletions(-) create mode 100644 getAuth.py create mode 100644 guiTesting.py create mode 100644 stationList.txt create mode 100644 stationlist.py diff --git a/getAuth.py b/getAuth.py new file mode 100644 index 0000000..09739e0 --- /dev/null +++ b/getAuth.py @@ -0,0 +1,49 @@ +import requests +import header_data +import json_data + + +def getTwoStepVerificationChallengeUrl(challengeRequest): + verificationChallengeCode = ( + challengeRequest.get("response") + .get("challenge") + .get("uri") + .split("?")[1] + .split("=")[1] + ) + return ( + "https://www.amazon.com/ap/challenge?openid.return_to=https://www.amazon.com/ap/maplanding&openid.oa2.code_challenge_method=S256&openid.assoc_handle=amzn_device_ios_us&pageId=amzn_device_ios_light&accountStatusPolicy=P1&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.mode=checkid_setup&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&openid.ns.oa2=http://www.amazon.com/ap/ext/oauth/2&openid.oa2.client_id=device:30324244334531423246314134354635394236443142424234413744443936452341334e5748585451344542435a53&language=en_US&openid.ns.pape=http://specs.openid.net/extensions/pape/1.0&openid.oa2.code_challenge=n76GtDRiGSvq-Bhrez9x0CypsZFB_7eLfEDy_qZtqFk&openid.oa2.scope=device_auth_access&openid.ns=http://specs.openid.net/auth/2.0&openid.pape.max_auth_age=0&openid.oa2.response_type=code" + + f"&arb={verificationChallengeCode}" + ) + + +def getAuthToken(): + """ + Get authorization token for Flex Capacity requests + Returns: + An access token as a string + """ + authUrl = "https://api.amazon.com/auth/register" + + try: + response = requests.post(authUrl, headers=header_data.authHeaders, json=json_data.auth_json_data).json() + return ( + response.get("response") + .get("success") + .get("tokens") + .get("bearer") + .get("access_token"), + response.get("request_id") + ) + + + except Exception as e: + twoStepVerificationChallengeUrl = getTwoStepVerificationChallengeUrl(response) + print("Unable to authenticate to Amazon Flex.") + print( + f"\nPlease try completing the two step verification challenge at \033[1m{twoStepVerificationChallengeUrl}\033[0m . Then try again." + ) + print( + "\nIf you already completed the two step verification, please check your Amazon Flex username and password in the config file and try again." + ) + diff --git a/guiTesting.py b/guiTesting.py new file mode 100644 index 0000000..a4d7a64 --- /dev/null +++ b/guiTesting.py @@ -0,0 +1,44 @@ +from appJar import gui + + +def press(button): + # if button == "Cancel": + # app.stop() + # else: + app.infoBox("Could be used if you catch a block", f"Block Length: xx mins\nBlock Pay: $125\nBlock Start Time: 11-10-22 8:25AM") + app.statusbar(text="Missed A Block") + + + + + +with gui("AFGrabber", "400x200", font={'size':14}) as app: + app.entry("Username", label=True, focus=True) + app.entry("Password", label=True, secret=True) + app.option("Max Block Length:", label=True, value=[3, 3.5, 4, 4.5, 5]) + app.entry("Min Pay Per Hour:", label=True) + app.buttons(["Start", "Cancel"], [press, app.stop]) + app.statusbar(text="Running") + + + + +# app = gui() +# app.addLabelEntry("Email:") +# app.addLabelSecretEntry("Password:") +# app.addLabelOptionBox("Max Block Length:", ["3", "3.5", "4", "4.5", "5"]) +# app.addLabelEntry("Min Per Hour:") +# app.addLabelEntry("Time Needed To Arrive:") +# app.addButtons(["Start", "Cancel"], press) +# #app.button('Accessibility', app.showAccess, icon='ACCESS') +# app.addMessage("Could Be Used As A Log") +# app.go() + + +# time.sleep(2) +# app.addMessage("To Keep Track Of") +# time.sleep(2) +# app.addMessage("Missed Blocks") +# time.sleep(2) +# app.addMessage("Or Just A Sanity Check") +# app.addMessage("To Know It's Running.") diff --git a/header_data.py b/header_data.py index 2184553..36febc1 100644 --- a/header_data.py +++ b/header_data.py @@ -16,3 +16,9 @@ # Leave these here to delete the unneeded headers that will cause problems running the script del headers["X-Flex-Client-Time"] del headers["X-Amz-Date"] + + +authHeaders = { + "x-amzn-identity-auth-domain": "api.amazon.com", + "User-Agent": "AmazonWebView/Amazon Flex/0.0/iOS/15.2/iPhone", + } \ No newline at end of file diff --git a/json_data.py b/json_data.py index 9506460..147e78e 100644 --- a/json_data.py +++ b/json_data.py @@ -18,6 +18,30 @@ ], } +auth_json_data = { + "requested_extensions": ["device_info", "customer_info"], + "cookies": {"website_cookies": [], "domain": ".amazon.com"}, + "registration_data": { + "domain": "Device", + "app_version": "0.0", + "device_type": "A3NWHXTQ4EBCZS", + "os_version": "15.2", + "device_serial": "0000000000000000", + "device_model": "iPhone", + "app_name": "Amazon Flex", + "software_version": "1", + }, + "auth_data": { + "user_id_password": { + "user_id": "SpamMe@FuhQ.com", + "password": "DefinitelyMyRealPassword", + } + }, + "user_context_map": {"frc": ""}, + "requested_token_type": ["bearer", "mac_dms", "website_cookies"], + } + + def accept_json_data(offerID): # This is the json data needed to accept a block, it takes an argument to extract the offer ID for the selected block diff --git a/main.py b/main.py index 4dd16a4..a952103 100644 --- a/main.py +++ b/main.py @@ -3,8 +3,10 @@ import time import json_data import header_data +import getAuth import logging import random +from appJar import gui logging.basicConfig(format="%(asctime)s \n\t%(message)s", level=logging.INFO) @@ -26,6 +28,8 @@ def get_offer_list(): return [accept_block(block) for block in j["offerList"] if filter_blocks(block)] except KeyError: return j["message"] + except: + header_data.headers['x-amz-access-token'], header_data.headers['X-Amzn-RequestId'] = getAuth.getAuthToken() def filter_blocks(block): @@ -57,8 +61,13 @@ def accept_block(block): return accept.status_code - -if __name__ == "__main__": +def press(button): + if button == "Cancel": + app.stop() + return None + else: + json_data.auth_json_data["auth_data"]["user_id_password"]["user_id"] = app.getEntry("Email:") + json_data.auth_json_data["auth_data"]["user_id_password"]["password"] = app.getEntry("Password:") keepItUp = True while keepItUp: @@ -72,3 +81,21 @@ def accept_block(block): break time.sleep(random.random()) + + + +if __name__ == "__main__": + + #header_data.headers['x-amz-access-token'], header_data.headers['X-Amzn-RequestId'] = getAuth.getAuthToken() + + app = gui() + app.addLabelEntry("Email:") + app.addLabelSecretEntry("Password:") + app.addLabelOptionBox("Max Block Length:", ["3", "3.5", "4", "4.5", "5"]) + app.addLabelEntry("Min Per Hour:") + app.button('Accessibility', app.showAccess, icon='ACCESS') + app.go() + + + + diff --git a/stationList.txt b/stationList.txt new file mode 100644 index 0000000..1f13ca6 --- /dev/null +++ b/stationList.txt @@ -0,0 +1,44 @@ +~~~~MIAMI-DADE~~~~ +29571892-da88-4089-83f0-24135852c2e4 Miami (UFL2) - Fresh Online +d39e54d6-1a53-46a9-a22d-309342256ef0 Miami Davie (C072) - Whole Foods +d15e18ec-66c7-42ae-8599-9f27f82b19cc Fort Lauderdale - (C465) Whole Foods +fd440da5-dc81-43bf-9afe-f4910bfd4090 Miami Pembroke Pines (C074) - Whole Foods +ffbac4b5-8850-48e8-86bd-4403685d46d7 Miami (DMI9) - Amazon.com +b90b085e-874f-48da-8150-b0c215efff08 South Miami (C314) - Whole Foods +f4342003-fb20-4761-9998-a1aca8133c23 Pompano Beach (DMF3)- Amazon.com +50ade688-5ae2-48ce-a83c-f0af3fa4a22a Virginia Gardens - (DMI3) AMZL +d98c442b-9688-4427-97b9-59a4313c2f66 Miami Downtown Miami (C073) - Whole Foods +d42d1888-f102-49e1-b524-6db352dd6d31 Hialeah (DMF1)- Amazon.com +a6b8cf91-1a26-495e-bc7a-6b7f5324a17d Miami (DVB7)-Amazon.com +dd00cb2b-349b-480c-a2d0-5aff2c3fd293 Sunrise - (DMI4) AMZL +fd409ef8-f297-4543-9b93-6a5e93184313 Miami - (DMI6) AMZL +a5e1a8d5-c368-4cb8-a2c6-3b71b3eb8178 Hialeah FL (VFL2) - Sub Same-Day +5540b055-ee3c-4274-9997-de65191d6932 Miami (UFL6) - Fresh Online +09cc7bbd-919c-4dec-be50-9a71ab0ca07e Mizner Park (PMAQ) - Retail Delivery +ad13a80a-0d93-444c-a660-1b5f65e53626 Pembroke Park (RFL1) - Community Delivery +5891b812-04ab-405b-8336-355a1f75e48e Pembroke Park (DVB5)-Amazon.com +00091261-49d3-4d1f-9720-d76cbd2b2401 Aventura Mall (PAAD) – Retail Delivery +724fcdc1-82a8-4cf9-90db-ba6f5b7e246e Miami Boca Raton (C070) - Whole Foods +c059f4c8-35bd-4a43-848f-38cb7d9eec9c Miami South Beach - (C492) Whole Foods +37fe42b7-2a8e-4aca-8b5d-7836e38ff1c4 Miami FL (NMI2) +49d080a7-a765-47cf-a29e-0f1842958d4a North Miami (C125) - Whole Foods +8c81c54f-6a60-405c-b095-43d9b9bc99c2 Tamarac FL (VFL3) - Sub Same-Day +f9530032-4659-4a14-b9e1-19496d97f633 Miami Dadeland (C071) - Whole Foods +e7765dce-8d20-41b6-a038-9856323d4db6 West Palm Beach - (DMI7) AMZL +5e29665d-f6d5-4ff2-8558-fc197eeb84a1 Fort Lauderdale (DFH1)- Amazon.com +12bb7066-fac1-4412-83e8-a63247d4a946 Miami West Palm Beach (C075) - Whole Foods +f78af44a-613a-4cea-bfd4-7ad17da2719d Miami (DMF5)- Amazon.com +dbff6260-ad56-4ee2-8ec0-423a12d8d7fa Deerfield Beach (DVB4)- Amazon.com +221c60b4-2825-4fdf-80de-360cdc73e8f4 Boca Raton (DMO6)- Amazon.com +ca2b3909-034b-4009-bbcb-1c27db8ae86c Town Center at Boca Raton (PTAI) - Retail Delivery +~~~~CLEVELAND~~~~ +191492ca-c629-4090-bc74-2dd82e74a21f Euclid - (DCL1) AMZL +a990b38b-a788-43e4-998b-881fa5989708 Cleveland University Center (C162) - Whole Foods +3b5d06e7-3186-4ff9-9165-4e298534c273 Cleveland (DCL7)- Amazon.com +6f6b6701-a672-472e-be2d-640e55f719ac Bedford (DCL4)-Amazon.com +9bd0adcb-33e5-4d77-aa0a-52534db8c16f Middleburg Heights OH (VOH1) - Sub Same-Day +0ed203a7-e371-4ed6-b44d-e73a2679917b Crocker Park (PCCF) - Retail Delivery +c0554d15-cf85-4914-aeb4-68290876d0d9 Eton Chagrin Boulevard (PEAM) - Retail Delivery +5f83bf59-c332-4ca9-815f-0de4cc2cbbf5 Cleveland Rocky River (C166) - Whole Foods +93db79b7-c32e-4c24-8802-dad137191594 Solon (DCM3)- Amazon.com +41895078-8477-4b70-ab92-60799ac6aa30 Brooklyn (DCL9) - Amazon.com \ No newline at end of file diff --git a/stationlist.py b/stationlist.py new file mode 100644 index 0000000..a4286e1 --- /dev/null +++ b/stationlist.py @@ -0,0 +1,136 @@ +stations = [ + { + "serviceAreaId": "29571892-da88-4089-83f0-24135852c2e4", + "serviceAreaName": "Miami (UFL2) - Fresh Online" + }, + { + "serviceAreaId": "d39e54d6-1a53-46a9-a22d-309342256ef0", + "serviceAreaName": "Miami Davie (C072) - Whole Foods" + }, + { + "serviceAreaId": "d15e18ec-66c7-42ae-8599-9f27f82b19cc", + "serviceAreaName": "Fort Lauderdale - (C465) Whole Foods" + }, + { + "serviceAreaId": "fd440da5-dc81-43bf-9afe-f4910bfd4090", + "serviceAreaName": "Miami Pembroke Pines (C074) - Whole Foods" + }, + { + "serviceAreaId": "ffbac4b5-8850-48e8-86bd-4403685d46d7", + "serviceAreaName": "Miami (DMI9) - Amazon.com" + }, + { + "serviceAreaId": "b90b085e-874f-48da-8150-b0c215efff08", + "serviceAreaName": "South Miami (C314) - Whole Foods" + }, + { + "serviceAreaId": "f4342003-fb20-4761-9998-a1aca8133c23", + "serviceAreaName": "Pompano Beach (DMF3)- Amazon.com" + }, + { + "serviceAreaId": "50ade688-5ae2-48ce-a83c-f0af3fa4a22a", + "serviceAreaName": "Virginia Gardens - (DMI3) AMZL" + }, + { + "serviceAreaId": "d98c442b-9688-4427-97b9-59a4313c2f66", + "serviceAreaName": "Miami Downtown Miami (C073) - Whole Foods" + }, + { + "serviceAreaId": "d42d1888-f102-49e1-b524-6db352dd6d31", + "serviceAreaName": "Hialeah (DMF1)- Amazon.com" + }, + { + "serviceAreaId": "a6b8cf91-1a26-495e-bc7a-6b7f5324a17d", + "serviceAreaName": "Miami (DVB7)-Amazon.com" + }, + { + "serviceAreaId": "dd00cb2b-349b-480c-a2d0-5aff2c3fd293", + "serviceAreaName": "Sunrise - (DMI4) AMZL" + }, + { + "serviceAreaId": "fd409ef8-f297-4543-9b93-6a5e93184313", + "serviceAreaName": "Miami - (DMI6) AMZL" + }, + { + "serviceAreaId": "a5e1a8d5-c368-4cb8-a2c6-3b71b3eb8178", + "serviceAreaName": "Hialeah FL (VFL2) - Sub Same-Day" + }, + { + "serviceAreaId": "5540b055-ee3c-4274-9997-de65191d6932", + "serviceAreaName": "Miami (UFL6) - Fresh Online" + }, + { + "serviceAreaId": "09cc7bbd-919c-4dec-be50-9a71ab0ca07e", + "serviceAreaName": "Mizner Park (PMAQ) - Retail Delivery" + }, + { + "serviceAreaId": "ad13a80a-0d93-444c-a660-1b5f65e53626", + "serviceAreaName": "Pembroke Park (RFL1) - Community Delivery" + }, + { + "serviceAreaId": "5891b812-04ab-405b-8336-355a1f75e48e", + "serviceAreaName": "Pembroke Park (DVB5)-Amazon.com" + }, + { + "serviceAreaId": "00091261-49d3-4d1f-9720-d76cbd2b2401", + "serviceAreaName": "Aventura Mall (PAAD) – Retail Delivery" + }, + { + "serviceAreaId": "724fcdc1-82a8-4cf9-90db-ba6f5b7e246e", + "serviceAreaName": "Miami Boca Raton (C070) - Whole Foods" + }, + { + "serviceAreaId": "c059f4c8-35bd-4a43-848f-38cb7d9eec9c", + "serviceAreaName": "Miami South Beach - (C492) Whole Foods" + }, + { + "serviceAreaId": "37fe42b7-2a8e-4aca-8b5d-7836e38ff1c4", + "serviceAreaName": "Miami FL (NMI2)" + }, + { + "serviceAreaId": "49d080a7-a765-47cf-a29e-0f1842958d4a", + "serviceAreaName": "North Miami (C125) - Whole Foods" + }, + { + "serviceAreaId": "8c81c54f-6a60-405c-b095-43d9b9bc99c2", + "serviceAreaName": "Tamarac FL (VFL3) - Sub Same-Day" + }, + { + "serviceAreaId": "f9530032-4659-4a14-b9e1-19496d97f633", + "serviceAreaName": "Miami Dadeland (C071) - Whole Foods" + }, + { + "serviceAreaId": "e7765dce-8d20-41b6-a038-9856323d4db6", + "serviceAreaName": "West Palm Beach - (DMI7) AMZL" + }, + { + "serviceAreaId": "5e29665d-f6d5-4ff2-8558-fc197eeb84a1", + "serviceAreaName": "Fort Lauderdale (DFH1)- Amazon.com" + }, + { + "serviceAreaId": "12bb7066-fac1-4412-83e8-a63247d4a946", + "serviceAreaName": "Miami West Palm Beach (C075) - Whole Foods" + }, + { + "serviceAreaId": "f78af44a-613a-4cea-bfd4-7ad17da2719d", + "serviceAreaName": "Miami (DMF5)- Amazon.com" + }, + { + "serviceAreaId": "dbff6260-ad56-4ee2-8ec0-423a12d8d7fa", + "serviceAreaName": "Deerfield Beach (DVB4)- Amazon.com" + }, + { + "serviceAreaId": "221c60b4-2825-4fdf-80de-360cdc73e8f4", + "serviceAreaName": "Boca Raton (DMO6)- Amazon.com" + }, + { + "serviceAreaId": "ca2b3909-034b-4009-bbcb-1c27db8ae86c", + "serviceAreaName": "Town Center at Boca Raton (PTAI) - Retail Delivery" + } + ] + + + +with open("stationlist.txt", "w") as file: + for station in stations: + file.write(f"{station['serviceAreaId']}\t{station['serviceAreaName']}\n") \ No newline at end of file