From 7e0946f777fa4c3d88a84d70033719cee58157a7 Mon Sep 17 00:00:00 2001 From: Lars Hennig Date: Thu, 24 Mar 2022 14:43:45 +0100 Subject: [PATCH] fix: non regional console url doesn't have xsrf token and the rest/v1.0 api doesn't seem to work as well anymore --- coto/clients/billing.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/coto/clients/billing.py b/coto/clients/billing.py index cd745d5..2547426 100644 --- a/coto/clients/billing.py +++ b/coto/clients/billing.py @@ -41,7 +41,7 @@ def _xsrf_token(self): def _get_xsrf_token(self): r = self.session()._get( - 'https://console.aws.amazon.com/billing/home?region=eu-central-1&state=hashArgs%23' + 'https://us-east-1.console.aws.amazon.com/billing/home?region=eu-central-1&state=hashArgs%23' ) if r.status_code != 200: @@ -51,7 +51,7 @@ def _get_xsrf_token(self): def _get(self, api): r = self.session()._get( - "https://console.aws.amazon.com/billing/rest/v1.0/{0}?state=hashArgs%23". + "https://us-east-1.console.aws.amazon.com/billing/rest/v1.0/{0}?state=hashArgs%23". format(api), headers={'x-awsbc-xsrf-token': self._xsrf_token()}) @@ -63,7 +63,7 @@ def _get(self, api): def _put(self, api, data=None): if data is None: r = self.session()._put( - "https://console.aws.amazon.com/billing/rest/v1.0/{0}?state=hashArgs%23". + "https://us-east-1.console.aws.amazon.com/billing/rest/v1.0/{0}?state=hashArgs%23". format(api), headers={ 'x-awsbc-xsrf-token': self._xsrf_token(), @@ -71,7 +71,7 @@ def _put(self, api, data=None): }) else: r = self.session()._put( - "https://console.aws.amazon.com/billing/rest/v1.0/{0}?state=hashArgs%23". + "https://us-east-1.console.aws.amazon.com/billing/rest/v1.0/{0}?state=hashArgs%23". format(api), headers={ 'x-awsbc-xsrf-token': self._xsrf_token(), @@ -319,7 +319,7 @@ def close_account(self): .. code-block:: python client.close_account() - + Returns: boolean: success """