Skip to content

Commit 0c445a0

Browse files
authored
Add header for internal use (#252)
* add internal header
1 parent 2820327 commit 0c445a0

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ python-dateutil
44
responses
55
mock
66
setuptools_scm
7+
MarkupSafe
8+
setuptools>=40.0
9+
configparser>=3.5

twitter_ads/client.py

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def __init__(self,
2929
self._access_token = access_token
3030
self._access_token_secret = access_token_secret
3131
self._options = kwargs.get('options', {})
32+
self._headers = kwargs.get('headers', {})
3233

3334
def __repr__(self):
3435
return '<{name} object at {mem} consumer_key={key}>'.format(
@@ -42,6 +43,11 @@ def options(self):
4243
"""Returns the options value."""
4344
return self._options
4445

46+
@property
47+
def headers(self):
48+
"""Returns the headers value."""
49+
return self._headers
50+
4551
@property
4652
def consumer_key(self):
4753
"""Returns the consumer_key value."""

twitter_ads/http.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ def __oauth_request(self):
7575
if 'headers' in self.options:
7676
headers.update(self.options['headers'].copy())
7777

78-
# internal-only
78+
# DEPRECATED: internal-only (Should pass a header to the client)
7979
if 'x-as-user' in self._client.options:
8080
headers['x-as-user'] = self._client.options.get('x-as-user')
81-
81+
# Add headers from the client to the request (Client headers take priority)
82+
for key, val in self._client.headers.items():
83+
headers[key] = val
8284
params = self.options.get('params', None)
8385
data = self.options.get('body', None)
8486
files = self.options.get('files', None)

0 commit comments

Comments
 (0)