Skip to content

Commit

Permalink
Add custom user agent
Browse files Browse the repository at this point in the history
  • Loading branch information
fguillot committed Oct 15, 2023
1 parent e2de8dd commit e90ae5c
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 49 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018-2022 Frédéric Guillot
Copyright (c) 2018-2023 Frédéric Guillot

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 8 additions & 2 deletions miniflux.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The MIT License (MIT)
#
# Copyright (c) 2018-2022 Frederic Guillot
# Copyright (c) 2018-2023 Frederic Guillot
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -26,6 +26,9 @@
import requests


DEFAULT_USER_AGENT = "Miniflux Python Client Library"


class ClientError(Exception):
def __init__(self, response):
self.status_code = response.status_code
Expand All @@ -49,14 +52,17 @@ def __init__(
password: str = None,
timeout: float = 30.0,
api_key: str = None,
user_agent: str = DEFAULT_USER_AGENT,
):
self._base_url = base_url
self._api_key = api_key
self._username = username
self._password = password
self._timeout = timeout
self._auth = (self._username, self._password) if not api_key else None
self._headers = {"X-Auth-Token": api_key} if api_key else None
self._headers = {"User-Agent": user_agent}
if api_key:
self._headers["X-Auth-Token"] = api_key

def _get_endpoint(self, path: str) -> str:
if len(self._base_url) > 0 and self._base_url[-1:] == "/":
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "miniflux"
version = "0.0.17"
version = "0.0.18"
description = "Client library for Miniflux"
readme = "README.rst"
requires-python = ">=3.7"
Expand Down
Loading

0 comments on commit e90ae5c

Please sign in to comment.