-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrevolut_fe_live.py
More file actions
88 lines (55 loc) · 1.87 KB
/
revolut_fe_live.py
File metadata and controls
88 lines (55 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from flask import *
import requests
import json
import time
import revolutAPI_live as rev
client_id = "YOUR CLIENT ID "
access_tokens = []
refresh_tokens = []
app = Flask(__name__)
client_assertion = "Long String"
@app.route("/")
def index():
return render_template("index.html")
@app.route("/callback")
def callback():
authorization_token = request.args.get('code')
headers = {
"Content-Type" : "application/x-www-form-urlencoded"
}
data = f"grant_type=authorization_code&client_id={client_id}&code={authorization_token}&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&client_assertion={client_assertion}"
r = requests.post("https://b2b.revolut.com/api/1.0/auth/token", data=data, headers=headers)
print(r.status_code)
print(r.text)
named_tuple = time.localtime() # get struct_time
time_string = time.strftime("%m/%d/%Y, %H:%M:%S", named_tuple)
print("start time:" + time_string)
response1 = r.text
response = json.loads(response1)
access_token = response["access_token"]
refresh_token = response["refresh_token"]
refresh_tokens.append(refresh_token)
#if len(access_tokens) >= 2:
# access_tokens.pop(0)
data = {}
data['access_token'] = []
data['access_token'].append(access_token)
with open('your_txt.txt', 'w') as outfile:
json.dump(data, outfile)
rev1 = rev.Revolut()
rev1.receive_counterparties()
print(r.status_code)
print(r.text)
time.sleep(2380)
rev1 = rev.Revolut()
rev1.receive_counterparties()
print(r.status_code)
print(r.text)
time.sleep(30)
rev1 = rev.Revolut()
rev1.receive_counterparties()
print(r.status_code)
print(r.text)
return render_template("index.html", authorization_token=authorization_token, access_token=access_token)
if __name__ == "__main__":
app.run()