Skip to content

Commit

Permalink
use the correct headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Kigstn committed Mar 3, 2022
1 parent fd43a6d commit 9cfbb3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions Backend/networking/bungieApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ async def get(
# ignore cookies
no_jar = aiohttp.DummyCookieJar()

# use the correct headers
request_headers = self.normal_headers if not with_token else self.auth_headers

try:
async with aiohttp_client_cache.CachedSession(
cache=self.cache, json_serialize=lambda x: orjson.dumps(x).decode(), cookie_jar=no_jar
Expand All @@ -104,7 +107,7 @@ async def get(
session=session,
method="GET",
route=route,
headers=self.normal_headers,
headers=request_headers,
params=params,
)

Expand All @@ -115,7 +118,7 @@ async def get(
session=session,
method="GET",
route=route,
headers=self.normal_headers,
headers=request_headers,
params=params,
)

Expand Down Expand Up @@ -152,12 +155,12 @@ async def post(self, route: str, json: dict = None, params: dict = None) -> WebR
async def __set_auth_headers(self):
"""Update the auth headers to include a working token. Raise an error if that doesnt exist"""

# get a working token or abort
auth = BungieAuth(db=self.db, user=self.user)
token = await auth.get_working_token()

# use special token headers if its a bungie request
if self.bungie_request:
# get a working token or abort
auth = BungieAuth(db=self.db, user=self.user)
token = await auth.get_working_token()

self.auth_headers.update(
{
"Authorization": f"Bearer {token}",
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.9"
__version__ = "1.0.10"

0 comments on commit 9cfbb3f

Please sign in to comment.