Skip to content
Open
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
15 changes: 8 additions & 7 deletions GrampsWebSync/webapihandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def fetch_metadata(self) -> None:
LOG.debug("Fetching metadata from the server")
req = Request(
f"{self.url}/metadata/",
headers={"Authorization": f"Bearer {self.access_token}"},
headers={"Authorization": f"Bearer {self.access_token}", "User-Agent": "GrampsWebSync"},
)
with urlopen(req, context=self._ctx) as res:
self._metadata = json.load(res)
Expand All @@ -162,7 +162,7 @@ def fetch_token(self) -> None:
req = Request(
f"{self.url}/token/",
data=data.encode(),
headers={"Content-Type": "application/json"},
headers={"Content-Type": "application/json", "User-Agent": "GrampsWebSync"},
)
try:
with urlopen(req, context=self._ctx) as res:
Expand Down Expand Up @@ -225,6 +225,7 @@ def commit(
headers={
"Content-Type": "application/json",
"Authorization": f"Bearer {self.access_token}",
"User-Agent": "GrampsWebSync"
},
)
json_response: dict | None = None
Expand Down Expand Up @@ -260,7 +261,7 @@ def update_task_status(
endpoint = f"{self.url}/tasks/{task_id}"
req = Request(
endpoint,
headers={"Authorization": f"Bearer {self.access_token}"},
headers={"Authorization": f"Bearer {self.access_token}", "User-Agent": "GrampsWebSync"},
)
try:
with urlopen(req, context=self._ctx) as res:
Expand All @@ -286,7 +287,7 @@ def get_missing_files(self, retry: bool = True) -> list:
"""Get a list of remote media objects with missing files."""
req = Request(
f"{self.url}/media/?filemissing=1",
headers={"Authorization": f"Bearer {self.access_token}"},
headers={"Authorization": f"Bearer {self.access_token}", "User-Agent": "GrampsWebSync"},
)
try:
with urlopen(req, context=self._ctx) as res:
Expand All @@ -305,11 +306,11 @@ def _download_file(
):
"""Download a file."""
if token_url:
req = Request(f"{url}?jwt={self.access_token}")
req = Request(f"{url}?jwt={self.access_token}", headers={"User-Agent": "GrampsWebSync"})
else:
req = Request(
url,
headers={"Authorization": f"Bearer {self.access_token}"},
headers={"Authorization": f"Bearer {self.access_token}", "User-Agent": "GrampsWebSync"},
)
try:
with urlopen(req, context=self._ctx) as res:
Expand Down Expand Up @@ -356,7 +357,7 @@ def _upload_file(self, url: str, fobj, retry: bool = True):
req = Request(
url,
data=fobj,
headers={"Authorization": f"Bearer {self.access_token}"},
headers={"Authorization": f"Bearer {self.access_token}", "User-Agent": "GrampsWebSync"},
method="PUT",
)
try:
Expand Down