diff --git a/tests/api/test_api_request_sender.py b/tests/api/test_api_request_sender.py index 39e7941..d99d8e0 100644 --- a/tests/api/test_api_request_sender.py +++ b/tests/api/test_api_request_sender.py @@ -26,7 +26,6 @@ def test_set_webhook_sanity(): def post_request(endpoint, payload): request = json.loads(payload) assert endpoint == BOT_API_ENDPOINT.SET_WEBHOOK - assert request['auth_token'] == VIBER_BOT_CONFIGURATION.auth_token assert request['event_types'] == webhook_events assert request['url'] == url return dict(status=0, event_types=webhook_events) @@ -56,7 +55,6 @@ def test_post_request_success(monkeypatch): def callback(endpoint, data, headers): request = json.loads(data) assert endpoint == VIBER_BOT_API_URL + "/" + BOT_API_ENDPOINT.GET_ACCOUNT_INFO - assert request['auth_token'] == VIBER_BOT_CONFIGURATION.auth_token assert headers['User-Agent'] == VIBER_BOT_USER_AGENT response = Stub() response.raise_for_status = stub @@ -124,7 +122,7 @@ def test_get_online_success(monkeypatch): def callback(endpoint, data, headers): request = json.loads(data) assert endpoint == VIBER_BOT_API_URL + "/" + BOT_API_ENDPOINT.GET_ONLINE - assert request['auth_token'] == VIBER_BOT_CONFIGURATION.auth_token + assert headers['X-Viber-Auth-Token'] == VIBER_BOT_CONFIGURATION.auth_token response = Stub() response.raise_for_status = stub response.text = "{\"status\": 0, \"status_message\": \"OK\", \"users\": []}" @@ -141,7 +139,7 @@ def test_get_user_details_success(monkeypatch): def callback(endpoint, data, headers): request = json.loads(data) assert endpoint == VIBER_BOT_API_URL + "/" + BOT_API_ENDPOINT.GET_USER_DETAILS - assert request['auth_token'] == VIBER_BOT_CONFIGURATION.auth_token + assert headers['X-Viber-Auth-Token'] == VIBER_BOT_CONFIGURATION.auth_token response = Stub() response.raise_for_status = stub response.text = "{\"status\": 0, \"status_message\": \"OK\", \"user\": {}}" diff --git a/viberbot/api/api_request_sender.py b/viberbot/api/api_request_sender.py index db9884a..90c5f3a 100644 --- a/viberbot/api/api_request_sender.py +++ b/viberbot/api/api_request_sender.py @@ -14,7 +14,6 @@ def __init__(self, logger, viber_bot_api_url, bot_configuration, viber_bot_user_ def set_webhook(self, url, webhook_events=None, is_inline=False): payload = { - 'auth_token': self._bot_configuration.auth_token, 'url': url, 'is_inline': is_inline } @@ -34,18 +33,17 @@ def set_webhook(self, url, webhook_events=None, is_inline=False): return result['event_types'] def get_account_info(self): - payload = { - 'auth_token': self._bot_configuration.auth_token - } return self.post_request( endpoint=BOT_API_ENDPOINT.GET_ACCOUNT_INFO, - payload=json.dumps(payload)) + payload=json.dumps(None) + ) def post_request(self, endpoint, payload): try: headers = requests.utils.default_headers() headers.update({ - 'User-Agent': self._user_agent + 'User-Agent': self._user_agent, + 'X-Viber-Auth-Token': self._bot_configuration.auth_token }) response = requests.post(self._viber_bot_api_url + '/' + endpoint, data=payload, headers=headers) response.raise_for_status() @@ -66,7 +64,6 @@ def get_online_status(self, ids=[]): raise Exception(u"missing parameter ids, should be a list of viber memberIds") payload = { - 'auth_token': self._bot_configuration.auth_token, 'ids': ids } result = self.post_request( @@ -83,7 +80,6 @@ def get_user_details(self, user_id): raise Exception(u"missing parameter id") payload = { - 'auth_token': self._bot_configuration.auth_token, 'id': user_id } result = self.post_request(