Skip to content

Commit

Permalink
🚚 chore: Move credential UserAuth.py to a new location
Browse files Browse the repository at this point in the history
  • Loading branch information
sudoskys committed Feb 17, 2024
1 parent 3e92ea3 commit 7e0ea99
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/novelai_python/credential/ApiToken.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ async def get_session(self, timeout: int = 180, update_headers: dict = None):
"Accept": "*/*",
"Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
"Accept-Encoding": "gzip, deflate, br",
"User-Agent": FAKE_UA.chrome,
"User-Agent": FAKE_UA.edge,
"Authorization": f"Bearer {self.api_token.get_secret_value()}",
"Content-Type": "application/json",
"Origin": "https://novelai.net",
"Referer": "https://novelai.net/",
}, impersonate="chrome110")
}, impersonate="edge101")
self._session.headers.update(update_headers)
return self._session

Expand Down
4 changes: 2 additions & 2 deletions src/novelai_python/credential/JwtToken.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ async def get_session(self, timeout: int = 180, update_headers: dict = None):
self._session = AsyncSession(timeout=timeout, headers={
"Accept": "*/*",
"Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
"User-Agent": FAKE_UA.chrome,
"User-Agent": FAKE_UA.edge,
"Accept-Encoding": "gzip, deflate, br",
"Authorization": f"Bearer {self.jwt_token.get_secret_value()}",
"Content-Type": "application/json",
"Origin": "https://novelai.net",
"Referer": "https://novelai.net/",
}, impersonate="chrome110")
}, impersonate="edge101")
assert isinstance(update_headers, dict), "update_headers must be a dict"
self._session.headers.update(update_headers)
return self._session
Expand Down
4 changes: 2 additions & 2 deletions src/novelai_python/credential/UserAuth.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ async def get_session(self, timeout: int = 180, update_headers: dict = None):
resp = await Login.build(user_name=self.username, password=self.password.get_secret_value()).request()
self._session = AsyncSession(timeout=timeout, headers={
"Accept": "*/*",
"User-Agent": FAKE_UA.chrome,
"User-Agent": FAKE_UA.edge,
"Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
"Accept-Encoding": "gzip, deflate, br",
"Authorization": f"Bearer {resp.accessToken}",
"Content-Type": "application/json",
"Origin": "https://novelai.net",
"Referer": "https://novelai.net/",
}, impersonate="chrome110")
}, impersonate="edge101")
self._update_at = int(time.time())
self._session.headers.update(update_headers)
return self._session
2 changes: 0 additions & 2 deletions src/novelai_python/credential/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

FAKE_UA = UserAgent()

print(FAKE_UA.chrome)


class CredentialBase(BaseModel):
_session: AsyncSession = None
Expand Down

0 comments on commit 7e0ea99

Please sign in to comment.