Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HTTP 403 when adding new user #134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions kobodl/kobo.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,28 @@ class KoboException(Exception):

class Kobo:
Affiliate = "Kobo"
ApplicationVersion = "8.11.24971"
ApplicationVersion = "10.1.2.39807"
CarrierName = "310270"
DefaultPlatformId = "00000000-0000-0000-0000-000000004000"
DeviceModel = "Pixel"
DeviceOsVersion = "33"
DisplayProfile = "Android"
UserAgent = "Mozilla/5.0 (Linux; Android 6.0; Google Nexus 7 2013 Build/MRA58K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.186 Safari/537.36 KoboApp/8.40.2.29861 KoboPlatform Id/00000000-0000-0000-0000-000000004000 KoboAffiliate/Kobo KoboBuildFlavor/global"
UserAgent = "Mozilla/5.0 (Linux; Android 13; Pixel Build/TQ2B.230505.005.A1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/101.0.4951.61 Safari/537.36 KoboApp/10.1.2.39807 KoboPlatform Id/00000000-0000-0000-0000-000000004000 KoboAffiliate/Kobo KoboBuildFlavor/global"

def __init__(self, user: User):
self.InitializationSettings = {}
self.Session = requests.session()
self.Session.headers.update({"User-Agent": Kobo.UserAgent})
self.Session.headers.update({
"User-Agent": Kobo.UserAgent,
"X-Requested-With": "com.kobobooks.android",
"x-kobo-affiliatename": Kobo.Affiliate,
"x-kobo-appversion": Kobo.ApplicationVersion,
"x-kobo-carriername": Kobo.CarrierName,
"x-kobo-devicemodel": Kobo.DeviceModel,
"x-kobo-deviceos": Kobo.DisplayProfile,
"x-kobo-deviceosversion": Kobo.DeviceOsVersion,
"x-kobo-platformid": Kobo.DefaultPlatformId,
})
self.user = user

# PRIVATE METHODS
Expand Down Expand Up @@ -139,6 +152,12 @@ def __GetExtraLoginParameters(self) -> Tuple[str, str, str]:
"pwsav": Kobo.ApplicationVersion,
"pwspid": Kobo.DefaultPlatformId,
"pwsdid": self.user.DeviceId,
"wscfv": "1.5",
"wscf": "kepub",
"wsmc": Kobo.CarrierName,
"pwspov": Kobo.DeviceOsVersion,
"pwspt": "Mobile",
"pwsdm": Kobo.DeviceModel,
}

response = self.Session.get(signInUrl, params=params)
Expand Down