Notes
Notes - notes.io |
import requests
from bs4 import BeautifulSoup
from urllib.parse import urlparse
from urllib.parse import parse_qs
def login_update_tokens():
url = "https://production.sureprep.com"
session = requests.Session()
session.headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"Accept-Language": "en-US,en;q=0.9"
}
response = session.get(url)
print("HomePage -> " + str(response.status_code))
if response.status_code == 200:
soup = BeautifulSoup(response.content, "html.parser") #whats happening here
form = soup.find("form")
if form:
token = soup.find('input', {'name': '__RequestVerificationToken'})['value']
print("__RequestVerificationToken -> " + token)
with open("data\headers\RequestVerificationToken.txt", 'w') as file:
file.write(token)
# post_body = "__RequestVerificationToken="+token+"&DomainName=TRCONT-01&UserName=MADHVARAJ&HiddenPassword=PPUuAq1GDRJg0BSI+m0H3A%3D%3D&password=124co6ko53&Querystring=0"
post_body = "__RequestVerificationToken="+token+"&DomainName=TRCONT-01&UserName=MADHVARAJ&HiddenPassword=PPUuAq1GDRJg0BSI%2Bm0H3A%3D%3D&password=9fn5j82fx6&Querystring=0"
session.headers = {
"Origin": "https://production.sureprep.com",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"Referer": "https://production.sureprep.com/",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.9",
# "Cookie": "hubspotutk=fe081af3504bc914b090bcb8797f47d3; _hjSessionUser_1111364=eyJpZCI6ImNmZGJkMTQyLTQ3YmEtNWY4My1iM2FjLWRiZTQxYjhhMjYxZCIsImNyZWF0ZWQiOjE2Nzg0MjkxODM1MjYsImV4aXN0aW5nIjp0cnVlfQ==; __hs_opt_out=no; _ga_KT03FSVEKR=GS1.1.1683804121.3.0.1683804121.60.0.0; __zlcmid=1GElsOaH60xw9iM; FirmIDSecured=sXtf2RLcskMVyTW4MMY/vQ==; _gcl_au=1.1.169570742.1688456730; ZendexURLSecured=; _ga_7YKP7LNQRT=GS1.2.1689665266.8.1.1689665355.52.0.0; amp_1c1b54=v5KaTJ88_JPk0OrfHGm7PE.MTYzNzQwOQ==..1h696njqf.1h6974sav.22.14.36; amp_6d4f54=hfZvVgN6G4NM52r1wM8_1Z.MTI1Njc2MTg=..1h6luc1uk.1h6luc1uk.d.a.n; UsernameSecured=jwO5iTU4Y1ySyVcTVxRLog==; _uetvid=8bb5a2e0bf0b11eda4e0350398bb99d7; _ga=GA1.2.1190095859.1675701507; __hstc=61539059.fe081af3504bc914b090bcb8797f47d3.1678429189655.1690377850584.1690967689826.6; _ga_15ZX8SW5VH=GS1.1.1690969674.9.0.1690969674.60.0.0; ASP.NET_SessionId=uwhf02sitfgp0iwqzhtueg3s; __RequestVerificationToken="+token
}
url = 'https://production.sureprep.com/Home/AuthenticateUser'
response = session.post(url, data=post_body) #call for url and body will sent along which is post_body
print("AuthenticateUser -> " + str(response.status_code))
# print(response.text)
# with open('temp.html', 'w') as file:
# file.write(response.text)
# if response.status_code == 302:
# print(response.status_code)
url = 'https://production.sureprep.com/Fileroom/Fileroom/taxCaddyRedirect?_=1692105206998r'
response = session.get(url)
print("taxCaddyRedirect -> " + str(response.status_code))
print(response.text)
response = response.json() # raw data is converted into python objects(dict)
print(response)
if "tokenUrl" in response:
tokenUrl = response["tokenUrl"] # retrives the value of"tokenUrl"
print("tokenUrl -> " + tokenUrl)
#it parses a part of tokenurl using urlparse to string and further parse_qs parses the string part to dict
pq = parse_qs(urlparse(tokenUrl).fragment) # because of # in URL
# print(pq)
fileroom = pq['/login?fileroom'][0]
# print(fileroom)
url = 'https://api.taxcaddy.com/api/v1/sureprep/authenticate?temporarytoken=' + fileroom
session.headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",
"Content-Type": "application/json",
"Accept": "application/json",
"Origin": "https://cpa.taxcaddy.com",
"Referer": "https://cpa.taxcaddy.com/",
# "Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.9"
}
response = session.post(url, data="")
print("sureprep/authenticate -> " + str(response.status_code))
# print(response.text)
response = response.json()
# print(response)
if "access_token" in response:
access_token = response["access_token"]
print("access_token -> " + access_token)
with open("data\headers\Authorization.txt", 'w') as file:
file.write("Bearer " + access_token)
jwt = response["jwt"]
print("jwt -> " + jwt)
with open("data\headers\x-sp-authorization-jwt.txt", 'w') as file:
file.write(jwt)
# exit()
else:
print("No form found on the page.")
else:
print("Failed to fetch the page. Status code:", response.status_code)
def login_update_tokens_stage():
url = "https://stage.sureprep.com"
session = requests.Session()
session.headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"Accept-Language": "en-US,en;q=0.9"
}
response = session.get(url)
print("HomePage -> " + str(response.status_code))
if response.status_code == 200:
soup = BeautifulSoup(response.content, "html.parser")
form = soup.find("form")
if form:
token = soup.find('input', {'name': '__RequestVerificationToken'})['value']
print("__RequestVerificationToken -> " + token)
post_body = "__RequestVerificationToken="+token+"&DomainName=TRCONT-01&UserName=MADHVARAJM&HiddenPassword=c7ECNbWaVlBkjLZr8BvMYw%3D%3D&password=xcyckw390d&Querystring=0"
session.headers = {
"Origin": "https://stage.sureprep.com",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"Referer": "https://production.sureprep.com/",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.9",
# "Cookie": "hubspotutk=fe081af3504bc914b090bcb8797f47d3; _hjSessionUser_1111364=eyJpZCI6ImNmZGJkMTQyLTQ3YmEtNWY4My1iM2FjLWRiZTQxYjhhMjYxZCIsImNyZWF0ZWQiOjE2Nzg0MjkxODM1MjYsImV4aXN0aW5nIjp0cnVlfQ==; __hs_opt_out=no; _ga_KT03FSVEKR=GS1.1.1683804121.3.0.1683804121.60.0.0; __zlcmid=1GElsOaH60xw9iM; FirmIDSecured=sXtf2RLcskMVyTW4MMY/vQ==; _gcl_au=1.1.169570742.1688456730; ZendexURLSecured=; _ga_7YKP7LNQRT=GS1.2.1689665266.8.1.1689665355.52.0.0; amp_1c1b54=v5KaTJ88_JPk0OrfHGm7PE.MTYzNzQwOQ==..1h696njqf.1h6974sav.22.14.36; amp_6d4f54=hfZvVgN6G4NM52r1wM8_1Z.MTI1Njc2MTg=..1h6luc1uk.1h6luc1uk.d.a.n; UsernameSecured=jwO5iTU4Y1ySyVcTVxRLog==; _uetvid=8bb5a2e0bf0b11eda4e0350398bb99d7; _ga=GA1.2.1190095859.1675701507; __hstc=61539059.fe081af3504bc914b090bcb8797f47d3.1678429189655.1690377850584.1690967689826.6; _ga_15ZX8SW5VH=GS1.1.1690969674.9.0.1690969674.60.0.0; ASP.NET_SessionId=uwhf02sitfgp0iwqzhtueg3s; __RequestVerificationToken="+token
}
url = 'https://stage.sureprep.com/Home/AuthenticateUser'
response = session.post(url, data=post_body)
print("AuthenticateUser -> " + str(response.status_code))
# print(response.text)
# with open('temp.html', 'w') as file:
# file.write(response.text)
# if response.status_code == 302:
# print(response.status_code)
url = 'https://stage.sureprep.com/Fileroom/Fileroom/taxCaddyRedirect?_=1692105206998r'
response = session.get(url)
print("taxCaddyRedirect -> " + str(response.status_code))
# print(response.text)
response = response.json()
# print(response)
if "tokenUrl" in response:
tokenUrl = response["tokenUrl"]
print("tokenUrl -> " + tokenUrl)
pq = parse_qs(urlparse(tokenUrl).fragment) # because of # in URL
# print(pq)
fileroom = pq['/login?fileroom'][0]
# print(fileroom)
url = 'https://stage.taxcaddy.com/api/v1/sureprep/authenticate?temporarytoken=' + fileroom
session.headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",
"Content-Type": "application/json",
"Accept": "application/json",
"Origin": "https://cpa.taxcaddy.com",
"Referer": "https://cpa.taxcaddy.com/",
# "Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.9"
}
response = session.post(url, data="")
print("sureprep/authenticate -> " + str(response.status_code))
# print(response.text)
response = response.json()
# print(response)
if "access_token" in response:
access_token = response["access_token"]
print("access_token -> " + access_token)
with open("data\headers\Authorization.txt", 'w') as file:
file.write("Bearer " + access_token)
jwt = response["jwt"]
print("jwt -> " + jwt)
with open("data\headers\x-sp-authorization-jwt.txt", 'w') as file:
file.write(jwt)
# exit()
else:
print("No form found on the page.")
else:
print("Failed to fetch the page. Status code:", response.status_code)
*************************************************
import json
import requests
import xlsxwriter
from login import login_update_tokens, login_update_tokens_stage
twofa_disabled_acounts = []
with open('C:\Users\C285147\Downloads\TestData\2FA\accounts_list_prod.txt', 'r') as file:
# with open('C:\Users\C285147\Downloads\TestData\2FA\accounts_list_stage.txt', 'r') as file:
twofa_disabled_acounts = [line.strip() for line in file.readlines()]
# print(twofa_disabled_acounts)
# exit()
wd = "C:\Users\C285147\Downloads\"
workbook = xlsxwriter.Workbook(wd + "0_Client_List.xlsx")
worksheet = workbook.add_worksheet(name="Client_List")
bold = workbook.add_format({'bold': 1, 'border': 1})
text_format = workbook.add_format({'text_wrap': True, 'border': 1})
row = 0
col = 0
worksheet.write_row(row, col, ["ID", "USER_ID", "EMAIL", "FIRST NAME", "LAST NAME", "2_F_A", "INVITE-STATUS",
"INVITE-CHECKBOX", "QUEST-STATUS", "QUEST-CHECKBOX", "FILE-TO-TAXDOC", "OWNER"],
bold)
row += 1
# set_column(first_col, last_col, width, cell_format, options)
worksheet.set_column(0, 0, 10)
worksheet.set_column(1, 1, 10)
worksheet.set_column(2, 2, 30)
worksheet.set_column(3, 3, 25)
worksheet.set_column(4, 4, 10)
worksheet.set_column(5, 5, 15)
worksheet.set_column(6, 6, 10)
worksheet.set_column(7, 7, 15)
worksheet.set_column(8, 8, 10)
worksheet.set_column(9, 9, 10)
with open("data\headers\Authorization.txt", "r") as f:
auth = f.read().strip()
with open("data\headers\x-sp-authorization-jwt.txt", "r") as f:
jwt = f.read().strip()
post_body = "{"taxYear":2022,"templateID":1,"specificID":9301,"pagination":{"pageSize":10000,"pageNumber":1},"sort":{"columnName":"TaxPayerFirstName","sortDirection":1},"filters":[{"filterID":22,"filterName":"Search Text","filterValues":[{"text":""}]}]}"
# stage
# post_body = "{"taxYear":2022,"templateID":1,"specificID":586,"pagination":{"pageSize":5000,"pageNumber":1},"sort":{"columnName":"TaxPayerFirstName","sortDirection":1},"filters":[{"filterID":22,"filterName":"Search Text","filterValues":[{"text":""}]}]}"
headers = {
"Authorization": auth,
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",
"Content-Type": "application/json",
"Accept": "application/json",
"x-sp-authorization-jwt": jwt,
"Origin": "https://stage-cpa.taxcaddy.com",
"Referer": "https://stage-cpa.taxcaddy.com/",
# "Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.9"
}
url = 'https://api.taxcaddy.com/api/v1/clientmanagement/986071/client/list'
# url = 'https://stage.taxcaddy.com/api/v1/clientmanagement/7949029/client/list'
print("Reading account status.")
r = requests.post(url, data=post_body, headers=headers)
print("Reading account status. " + str(r.status_code))
response = r.json()
# print(response)
# exit()
data_collected = {}
if "error" in response and response["error"] != "":
print(response["error"])
if "Authorization has been denied" in response["error"]:
# login_update_tokens_stage()
login_update_tokens()
exit()
elif "Message" in response and response["Message"] != "":
print(response["Message"])
if "Authorization has been denied" in response["Message"]:
# login_update_tokens_stage()
login_update_tokens()
exit()
else:
if "response" in response:
response = response["response"]
clientCount = response["clientCount"]
print("Total : " + str(clientCount))
listDTOClientDetails = response["listDTOClientDetails"]
for listDTOClientDetail in listDTOClientDetails:
clientStatus = listDTOClientDetail["clientStatus"]
id = listDTOClientDetail["id"]
userId = listDTOClientDetail["userId"]
status = listDTOClientDetail["status"]
taxPayerEmail = listDTOClientDetail["taxPayerEmail"]
isCheckbox_enabled = listDTOClientDetail["isCheckbox_enabled"]
taxPayerFirstName = listDTOClientDetail["taxPayerFirstName"]
taxPayerLastName = listDTOClientDetail["taxPayerLastName"]
ownerFirstName = listDTOClientDetail["ownerFirstName"]
# print(id, clientStatus, isCheckbox_enabled)
data_collected[id] = {
"userId": userId,
"taxPayerEmail": taxPayerEmail,
"taxPayerFirstName": taxPayerFirstName,
"taxPayerLastName": taxPayerLastName,
"ownerFirstName": ownerFirstName,
"invite-status": status,
"invite-isCheckbox_enabled": isCheckbox_enabled
}
# worksheet.write_row(row, col, [id, taxPayerEmail, status, isCheckbox_enabled, clientStatus, taxPayerFirstName, taxPayerLastName], text_format)
# row += 1
# workbook.close()
# print(data_collected)
# prod
post_body = "{"taxYear":2022,"templateID":3,"specificID":7314,"pagination":{"pageSize":10000,"pageNumber":1},"sort":{"columnName":"TaxPayerFirstName","sortDirection":1},"filters":[{"filterID":22,"filterName":"Search Text","filterValues":[{"text":""}]}]}"
# stage
# post_body = "{"taxYear":2022,"templateID":3,"specificID":257,"pagination":{"pageSize":5000,"pageNumber":1},"sort":{"columnName":"TaxPayerFirstName","sortDirection":1},"filters":[{"filterID":22,"filterName":"Search Text","filterValues":[{"text":""}]}]}"
url = 'https://api.taxcaddy.com/api/v1/clientmanagement/986071/client/list'
# url = 'https://stage.taxcaddy.com/api/v1/clientmanagement/7949029/client/list'
print("Reading questionarie status.")
r = requests.post(url, data=post_body, headers=headers)
print("Reading questionarie status. " + str(r.status_code))
response = r.json()
# print(response)
if "error" in response and response["error"] != "":
print(response["error"])
if "Authorization has been denied" in response["error"]:
# login_update_tokens_stage()
login_update_tokens()
exit()
elif "Message" in response and response["Message"] != "":
print(response["Message"])
if "Authorization has been denied" in response["Message"]:
# login_update_tokens_stage()
login_update_tokens()
exit()
else:
if "response" in response:
response = response["response"]
clientCount = response["clientCount"]
print("Total : " + str(clientCount))
listDTOClientDetails = response["listDTOClientDetails"]
for listDTOClientDetail in listDTOClientDetails:
# clientStatus = listDTOClientDetail["clientStatus"]
id = listDTOClientDetail["id"]
status = listDTOClientDetail["status"]
# taxPayerEmail = listDTOClientDetail["taxPayerEmail"]
isCheckbox_enabled = listDTOClientDetail["isCheckbox_enabled"]
# taxPayerFirstName = listDTOClientDetail["taxPayerFirstName"]
# taxPayerLastName = listDTOClientDetail["taxPayerLastName"]
# print(id, clientStatus, isCheckbox_enabled)
data_collected[id]["quest-status"]=status
data_collected[id]["quest-isCheckbox_enabled"]=isCheckbox_enabled
# worksheet.write_row(row, col, [id, taxPayerEmail, status, isCheckbox_enabled, clientStatus, taxPayerFirstName, taxPayerLastName], text_format)
# row += 1
# workbook.close()
# print(data_collected)
# worksheet.write_row(row, col, ["ID", "EMAIL", "FIRST NAME", "LAST NAME", "INVITE-STATUS", "INVITE-CHECKBOX", "QUEST-STATUS", "INVITE-CHECKBOX"],
for id, c in data_collected.items():
worksheet.write_row(row, col, [id, c["userId"], c["taxPayerEmail"], c["taxPayerFirstName"], c["taxPayerLastName"],
"Yes" if c["taxPayerEmail"] in twofa_disabled_acounts else "No",
c["invite-status"], c["invite-isCheckbox_enabled"], c["quest-status"],
c["quest-isCheckbox_enabled"], "", c["ownerFirstName"] ], text_format)
# break
row += 1
workbook.close()
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team