Merge pull request #361 from fronzbot/add-user-agent-everywhere
Add user agent to all headers
This commit is contained in:
+7
-2
@@ -6,7 +6,12 @@ from requests.adapters import HTTPAdapter
|
|||||||
from urllib3.util.retry import Retry
|
from urllib3.util.retry import Retry
|
||||||
from blinkpy import api
|
from blinkpy import api
|
||||||
from blinkpy.helpers import util
|
from blinkpy.helpers import util
|
||||||
from blinkpy.helpers.constants import BLINK_URL, LOGIN_ENDPOINT, TIMEOUT
|
from blinkpy.helpers.constants import (
|
||||||
|
BLINK_URL,
|
||||||
|
DEFAULT_USER_AGENT,
|
||||||
|
LOGIN_ENDPOINT,
|
||||||
|
TIMEOUT,
|
||||||
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -53,7 +58,7 @@ class Auth:
|
|||||||
"""Return authorization header."""
|
"""Return authorization header."""
|
||||||
if self.token is None:
|
if self.token is None:
|
||||||
return None
|
return None
|
||||||
return {"TOKEN_AUTH": self.token}
|
return {"TOKEN_AUTH": self.token, "user-agent": DEFAULT_USER_AGENT}
|
||||||
|
|
||||||
def create_session(self, opts=None):
|
def create_session(self, opts=None):
|
||||||
"""Create a session for blink communication."""
|
"""Create a session for blink communication."""
|
||||||
|
|||||||
+1
-1
@@ -128,7 +128,7 @@ class TestAuth(unittest.TestCase):
|
|||||||
def test_header(self):
|
def test_header(self):
|
||||||
"""Test header data."""
|
"""Test header data."""
|
||||||
self.auth.token = "bar"
|
self.auth.token = "bar"
|
||||||
expected_header = {"TOKEN_AUTH": "bar"}
|
expected_header = {"TOKEN_AUTH": "bar", "user-agent": const.DEFAULT_USER_AGENT}
|
||||||
self.assertDictEqual(self.auth.header, expected_header)
|
self.assertDictEqual(self.auth.header, expected_header)
|
||||||
|
|
||||||
def test_header_no_token(self):
|
def test_header_no_token(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user