Skip to content

Commit

Permalink
api_client: don't accept cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
aviau committed Aug 20, 2024
1 parent 7c38128 commit 5013272
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions flareio/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from datetime import datetime
from datetime import timedelta
from http.cookiejar import DefaultCookiePolicy
from requests.adapters import HTTPAdapter
from urllib.parse import urljoin
from urllib.parse import urlparse
Expand Down Expand Up @@ -32,19 +33,28 @@ def __init__(
@staticmethod
def _create_session() -> requests.Session:
session = requests.Session()
retries = Retry(
total=5,
backoff_factor=2,
status_forcelist=[429, 502, 503, 504],
allowed_methods={"GET", "POST"},
backoff_max=15,

# Don't accept cookies.
session.cookies.set_policy(
policy=DefaultCookiePolicy(
allowed_domains=[],
),
)

# Enable retries
session.mount(
"https://",
HTTPAdapter(
max_retries=retries,
max_retries=Retry(
total=5,
backoff_factor=2,
status_forcelist=[429, 502, 503, 504],
allowed_methods={"GET", "POST"},
backoff_max=15,
)
),
)

return session

def generate_token(self) -> str:
Expand Down

0 comments on commit 5013272

Please sign in to comment.