Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Commit

Permalink
authentication: remove liap as required cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
sumnerevans committed Jul 13, 2021
1 parent 7029ba6 commit cad8d71
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v0.2.1

* Removed `liap` cookie as required for being authenticated.

# v0.2.0

* Implemented logout endpoint.
Expand Down
4 changes: 1 addition & 3 deletions examples/get-conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,4 @@ async def main():


loop = asyncio.get_event_loop()
asyncio.ensure_future(main())
loop.run_forever()
loop.close()
loop.run_until_complete(main())
4 changes: 1 addition & 3 deletions examples/listen-for-events.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,4 @@ async def on_event(event: RealTimeEventStreamEvent):


loop = asyncio.get_event_loop()
asyncio.ensure_future(main())
loop.run_forever()
loop.close()
loop.run_until_complete(main())
4 changes: 1 addition & 3 deletions examples/pickle-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,4 @@ async def main():


loop = asyncio.get_event_loop()
asyncio.ensure_future(main())
loop.run_forever()
loop.close()
loop.run_until_complete(main())
4 changes: 1 addition & 3 deletions examples/send-message.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,4 @@ async def main():


loop = asyncio.get_event_loop()
asyncio.ensure_future(main())
loop.run_forever()
loop.close()
loop.run_until_complete(main())
4 changes: 1 addition & 3 deletions examples/simple-2fa.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@ async def main():


loop = asyncio.get_event_loop()
asyncio.ensure_future(main())
loop.run_forever()
loop.close()
loop.run_until_complete(main())
2 changes: 1 addition & 1 deletion linkedin_messaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from .api_objects import URN

__title__ = "linkedin_messaging"
__version__ = "0.2.0"
__version__ = "0.2.1"
__description__ = "An unofficial API for interacting with LinkedIn Messaging"

__license__ = "MIT"
Expand Down
13 changes: 4 additions & 9 deletions linkedin_messaging/linkedin.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,7 @@ async def _post(self, relative_url: str, **kwargs: Any) -> aiohttp.ClientRespons
@property
def has_auth_cookies(self) -> bool:
cookie_names = {c.key for c in self.session.cookie_jar}
return (
"liap" in cookie_names
and "li_at" in cookie_names
and "JSESSIONID" in cookie_names
)
return "li_at" in cookie_names and "JSESSIONID" in cookie_names

async def logged_in(self) -> bool:
if not self.has_auth_cookies:
Expand Down Expand Up @@ -198,10 +194,9 @@ async def enter_2fa(self, two_factor_code: str):
raise Exception("Failed to log in.")

async def logout(self) -> bool:
csrf_token = None
for c in self.session.cookie_jar:
if c.key == "JSESSIONID":
csrf_token = c.value.strip('"')
csrf_token = self.session.headers.get("csrf-token")
if not csrf_token:
return True
response = await self.session.get(
LOGOUT_URL,
params={"csrfToken": csrf_token},
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "linkedin_messaging"
version = "0.2.0"
version = "0.2.1"
description = "An unofficial API for interacting with LinkedIn Messaging"
authors = ["Sumner Evans <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit cad8d71

Please sign in to comment.