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

Enable access token useage #586

Merged
merged 5 commits into from
Dec 9, 2024
Merged
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
17 changes: 11 additions & 6 deletions steam/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ def clear(self) -> None:
)

async def request(
self, method: str, url: StrOrURL, /, api_needs_auth: bool = True, **kwargs: Any
self,
method: str,
url: StrOrURL,
/,
api_needs_auth: bool = True,
supports_access_token: bool = True,
**kwargs: Any,
) -> Any: # adapted from d.py
kwargs["headers"] = {"User-Agent": self.user_agent, **kwargs.get("headers", {})}
payload = kwargs.get("data")
Expand All @@ -88,11 +94,10 @@ async def request(

if url.host == URL.API.host:
if api_needs_auth:
kwargs["params"] |= ( # if valve ever decide to make this work, this'd be nice
# {"access_token": await self._client._state.ws.access_token()}
# if self._client._state.login_complete.is_set()
# else
{"key": await self.get_api_key()}
kwargs["params"] |= (
{"access_token": await self._client._state.ws.access_token()}
if self._client._state.login_complete.is_set() and supports_access_token
else {"key": await self.get_api_key()}
)

elif url.host in (URL.COMMUNITY.host, URL.STORE.host, URL.HELP.host):
Expand Down
Loading