Skip to content

Commit

Permalink
fix: add session cookies to all update queries (if needed)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Nov 10, 2023
1 parent d2d0805 commit e3b0de0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions openfoodfacts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ def send_get_request(
def send_for_urlencoded_post_request(
url: str, body: Dict[str, Any], api_config: APIConfig
) -> requests.Response:
cookies = None
if api_config.username and api_config.password:
body["user_id"] = api_config.username
body["password"] = api_config.password
elif api_config.session_cookie:
cookies = {
"session": api_config.session_cookie,
}
r = http_session.post(
url,
data=body,
timeout=api_config.timeout,
auth=get_http_auth(api_config.environment),
cookies=cookies,
)
r.raise_for_status()
return r
Expand Down

0 comments on commit e3b0de0

Please sign in to comment.