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

New auth pattern #303

Merged
merged 4 commits into from
Oct 24, 2023
Merged

New auth pattern #303

merged 4 commits into from
Oct 24, 2023

Conversation

wolfovik
Copy link
Contributor

@wolfovik wolfovik commented Oct 22, 2023

Tested login and inventory.

patch by nbordin
@bukson
Copy link
Owner

bukson commented Oct 23, 2023

I will test it and review today, thanks!

@staticmethod
def _create_cookie(name: str, cookie: str, domain: str) -> dict:
return {"name": name,
"value": cookie,
"domain": domain}

def _fetch_rsa_params(self, current_number_of_repetitions: int = 0) -> dict:
self.session.post(SteamUrl.COMMUNITY_URL)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this post, it seems to be doing nothing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required for the initialization of the session with which we will work.

steampy/login.py Outdated
self.session.cookies.set(**community_cookie)
self.session.cookies.set(**store_cookie)

@staticmethod
def _create_cookie(name: str, cookie: str, domain: str) -> dict:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move that to utils please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

steampy/login.py Outdated

def _fetch_home_page(self, session: Session) -> Response:
return session.post(SteamUrl.COMMUNITY_URL + '/my/home/')

def _update_steam_guard(self, login_response: Response) -> bool:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should return None as it just changes internal state, and we never use its value if it is ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

steampy/login.py Outdated
else:
raise Exception('Cannot update steam guard')

def _pool_sessions_steam(self, client_id, request_id):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add types please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

steampy/login.py Outdated
response = self._api_call('POST', 'IAuthenticationService', 'PollAuthSessionStatus', params = pool_data)
self.refresh_token = response.json()["response"]["refresh_token"]

def _finallize_login(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add return type and fix typo, should be _finalize_login

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

steampy/login.py Outdated
sessionid = self.session.cookies["sessionid"]
redir = "https://steamcommunity.com/login/home/?goto="

finallez_data = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix typo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

steampy/login.py Outdated

def _finallize_login(self):
sessionid = self.session.cookies["sessionid"]
redir = "https://steamcommunity.com/login/home/?goto="
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change variable name to be more descriptive and use COMMUNITY_URL

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@bukson
Copy link
Owner

bukson commented Oct 23, 2023

Please resolve the comments

Also if you can research the logout method, I was able to pass login test, but logout was unsucesfull.

I can merge this without logout working but it will be probably next complain.

patch by nbordin
fixed
@wolfovik
Copy link
Contributor Author

wolfovik commented Oct 23, 2023

Please resolve the comments

Also if you can research the logout method, I was able to pass login test, but logout was unsucesfull.

I can merge this without logout working but it will be probably next complain.

I've never used the Logout function all these years.

P.S. Taking this opportunity, I'd like to thank you for this wonderful project!

@wolfovik wolfovik requested a review from bukson October 23, 2023 23:10
@bukson bukson merged commit 7e6e012 into bukson:master Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants