Replace token with seed and obtain token from seed + fix bug

Bug = getting data from dict
This commit is contained in:
PCoder 2019-08-13 14:48:50 +05:30
parent 1b8c8793f0
commit 3e6d535a74
1 changed files with 11 additions and 4 deletions

View File

@ -1,5 +1,6 @@
import urllib.request
import json
from pyotp import TOTP
UNGLEICH_PAY_SERVER_URL = "https://pay.ungleich.ch"
@ -15,8 +16,12 @@ class ungleichPay(object):
self.parser['customers-list'].add_argument('--username', required=True)
self.parser['customers-list'].add_argument('--realm', required=True)
self.parser['customers-list'].add_argument(
'--token', required=True,
help="A valid token obtained from ungleich"
'--seed', required=True,
help="A valid seed obtained from ungleich"
)
self.parser['customers-list'].add_argument(
'--email', required=True,
help="Email associated with the username"
)
self.parser['customers-list'].add_argument(
'--ungleich-pay-server', required=False,
@ -30,14 +35,16 @@ class ungleichPay(object):
request_url = args.ungleich_pay_server + customers_list_endpoint
else:
request_url = UNGLEICH_PAY_SERVER_URL + customers_list_endpoint
print(f"request_url={request_url}")
req = urllib.request.Request(url=request_url,
method='GET',
headers={
"email": args.email,
"username": args.username,
"realm": args.realm,
"token": args.token,
"token": TOTP(args.seed).now(),
"Accept": "application/json"
})
response = urllib.request.urlopen(req)
response_json = json.loads(response.read().decode('utf-8'))
print(response_json.data)
print(response_json["data"])