Skip to content

Commit

Permalink
Enable access token useage (#586)
Browse files Browse the repository at this point in the history
* Update http.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add flag to be able to tune this

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: James Hilton-Balfe <[email protected]>
  • Loading branch information
3 people authored Dec 9, 2024
1 parent fec1b31 commit c4ffde7
Showing 1 changed file with 11 additions and 6 deletions.
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

0 comments on commit c4ffde7

Please sign in to comment.