Skip to content
This repository was archived by the owner on Sep 9, 2022. It is now read-only.

Commit a5286ef

Browse files
committed
fixup! add biometric login
1 parent 2e816d2 commit a5286ef

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

revolut/__init__.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
API_BASE = "https://api.revolut.com"
1515
_URL_GET_ACCOUNTS = API_BASE + "/user/current/wallet"
16-
_URL_GET_TRANSACTIONS_LAST = API_BASE +'/user/current/transactions/last'
16+
_URL_GET_TRANSACTIONS_LAST = API_BASE + "/user/current/transactions/last"
1717
_URL_QUOTE = API_BASE + "/quote/"
1818
_URL_EXCHANGE = API_BASE + "/exchange"
1919
_URL_GET_TOKEN_STEP1 = API_BASE + "/signin"
@@ -146,14 +146,16 @@ def _get(self, url, *, expected_status_code=200, **kwargs):
146146
ret = self.session.get(url=url, **kwargs)
147147
if ret.status_code != expected_status_code:
148148
raise ConnectionError(
149-
f'Status code {ret.status_code} for url {url}\n{ret.text}')
149+
'Status code {} for url {}\n{}'.format(
150+
ret.status_code, url, ret.text))
150151
return ret
151152

152153
def _post(self, url, *, expected_status_code=200, **kwargs):
153154
ret = self.session.post(url=url, **kwargs)
154155
if ret.status_code != expected_status_code:
155156
raise ConnectionError(
156-
f'Status code {ret.status_code} for url {url}\n{ret.text}')
157+
'Status code {} for url {}\n{}'.format(
158+
ret.status_code, url, ret.text))
157159
return ret
158160

159161

@@ -471,7 +473,7 @@ def get_token_step1(device_id, phone, password, simulate=False):
471473
c = Client(device_id=device_id, token=_DEFAULT_TOKEN_FOR_SIGNIN)
472474
data = {"phone": phone, "password": password}
473475
ret = c._post(_URL_GET_TOKEN_STEP1, json=data)
474-
channel = ret.json().get('channel')
476+
channel = ret.json().get("channel")
475477
return channel
476478

477479

@@ -506,17 +508,17 @@ def get_token_step2(device_id, phone, code, simulate=False):
506508
def extract_token(json_response):
507509
user_id = json_response["user"]["id"]
508510
access_token = json_response["accessToken"]
509-
token_to_encode = f'{user_id}:{access_token}'.encode('ascii')
511+
token_to_encode = '{}:{}'.format(user_id, access_token).encode("ascii")
510512
# Ascii encoding required by b64encode function : 8 bits char as input
511513
token = base64.b64encode(token_to_encode)
512-
return token.decode('ascii')
514+
return token.decode("ascii")
513515

514516

515517
def signin_biometric(device_id, phone, access_token, selfie_filepath):
516-
files = {'selfie': open(selfie_filepath,'rb')}
518+
files = {"selfie": open(selfie_filepath, "rb")}
517519
c = Client(device_id=device_id, token=_DEFAULT_TOKEN_FOR_SIGNIN)
518520
c.session.auth = (phone, access_token)
519-
res = c._post('https://api.revolut.com/biometric-signin/selfie', files=files)
520-
biometric_id = res.json()['id']
521-
res = c._post(f'https://api.revolut.com/biometric-signin/confirm/{biometric_id}')
521+
res = c._post(API_BASE + "/biometric-signin/selfie", files=files)
522+
biometric_id = res.json()["id"]
523+
res = c._post(API_BASE + "/biometric-signin/confirm/" + biometric_id)
522524
return res.json()

0 commit comments

Comments
 (0)