-
-
Notifications
You must be signed in to change notification settings - Fork 388
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: logout #197
base: master
Are you sure you want to change the base?
Feature: logout #197
Conversation
linkedin_api/linkedin.py
Outdated
"takeoverFlow": "SIGN_OUT", | ||
} | ||
url = f"/takeovers" | ||
url_params["updateId"] = "activity:" + post_urn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this line required?
linkedin_api/linkedin.py
Outdated
@@ -96,6 +96,21 @@ def _post(self, uri, evade=default_evade, base_request=False, **kwargs): | |||
url = f"{self.client.API_BASE_URL if not base_request else self.client.LINKEDIN_BASE_URL}{uri}" | |||
return self.client.session.post(url, **kwargs) | |||
|
|||
def logout(self): | |||
"""GET request to log user out""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think its necessary to mention it is a GET request. It would be enough to just mention what the method does. In this case it could . Logs out of the current session
.
What is your opinion on having a return type of bool
which would be true on success and false on failure to logout.
url_params = { | ||
"q": "takeoverFlow", | ||
"takeoverFlow": "SIGN_OUT", | ||
} | ||
url = f"/takeovers" | ||
url_params["updateId"] = "activity:" + post_urn | ||
res = self._fetch(url, params=url_params) | ||
data = res.json() | ||
if data and "status" in data and data["status"] != 200: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you forgot to remove these 3 lines.
res = self._fetch(url, params=url_params) | ||
data = res.json() | ||
if data and "status" in data and data["status"] != 200: | ||
self.logger.info("request failed: {}".format(data["status"])) | ||
return {} | ||
return data | ||
if data and "status" in data and data["status"] == 200: | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No harm in keeping the logging statement when the request returns failure
Just confirming, did you try testing the other available methods after logout. Ideally they shouldn鈥檛 work and throw some errors after the logout. Could you please confirm the behaviour? |
@alvaroserrrano @abinpaul1 is this pull request valid, it is a very important feature logout from the current session. I have tried it and it returns |
I am not sure if the changes in this PR were tested. @alvaroserrrano can maybe confirm. @engahmed1190 Are you able to use other methods after logout is called? |
The session is still active after using the |
Oh, then it seems we have missed some logic in the logout flow. We currently only do a get request to endpoint mentioned in #191 . It requires further investigation i suppose |
No description provided.