Skip to content

Commit

Permalink
Merge 8c3cfe7 into 567ea52
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Willer committed Oct 5, 2018
2 parents 567ea52 + 8c3cfe7 commit 7d1a622
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions boxsdk/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import unicode_literals, absolute_import

from sys import version_info as py_version

from . import version


Expand All @@ -17,3 +19,9 @@ class Client(object):
"""Configuration object containing the user agent string."""
VERSION = version.__version__
USER_AGENT_STRING = 'box-python-sdk-{0}'.format(VERSION)
BOX_UA_STRING = 'agent=box-python-sdk/{0}; env=python/{1}.{2}.{3}'.format(
VERSION,
py_version.major,
py_version.minor,
py_version.micro,
)
5 changes: 4 additions & 1 deletion boxsdk/session/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ def __init__(
self._client_config = client_config or Client()
super(Session, self).__init__()
self._network_layer = network_layer or DefaultNetwork()
self._default_headers = {'User-Agent': self._client_config.USER_AGENT_STRING}
self._default_headers = {
'User-Agent': self._client_config.USER_AGENT_STRING,
'X-Box-UA': self._client_config.BOX_UA_STRING,
}
self._translator = translator
self._default_network_request_kwargs = {}
if default_headers:
Expand Down
1 change: 1 addition & 0 deletions test/integration/test_as_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def as_user_headers(mock_user_id, access_token):
'Authorization': 'Bearer {0}'.format(access_token),
'As-User': mock_user_id,
'User-Agent': Client.USER_AGENT_STRING,
'X-Box-UA': Client.BOX_UA_STRING,
}


Expand Down
2 changes: 1 addition & 1 deletion test/integration/test_retry_and_refresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_automatic_refresh(
'POST',
'{0}/token'.format(API.OAUTH2_API_URL),
data=ANY,
headers={'content-type': 'application/x-www-form-urlencoded', 'User-Agent': ANY},
headers={'content-type': 'application/x-www-form-urlencoded', 'User-Agent': ANY, 'X-Box-UA': ANY},
),
call(
'GET',
Expand Down
1 change: 1 addition & 0 deletions test/integration/test_with_shared_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def box_api_headers(shared_link, shared_link_password, access_token):
'Authorization': 'Bearer {0}'.format(access_token),
'BoxApi': box_api_header,
'User-Agent': Client.USER_AGENT_STRING,
'X-Box-UA': Client.BOX_UA_STRING,
}


Expand Down

0 comments on commit 7d1a622

Please sign in to comment.