Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: non regional console url doesn't have xsrf token and the rest/v1… #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions coto/clients/billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()})

Expand All @@ -63,15 +63,15 @@ 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(),
'Content-Type': 'application/json',
})
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(),
Expand Down Expand Up @@ -319,7 +319,7 @@ def close_account(self):
.. code-block:: python

client.close_account()

Returns:
boolean: success
"""
Expand Down