-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheduler_script.py
31 lines (24 loc) · 1.02 KB
/
scheduler_script.py
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
#!/usr/bin/env python3
import os
import requests
import json
import time
url = "http://10.104.235.97:8080/auth/realms/test/protocol/openid-connect/token"
payload=f'client_id=binder-oauth-client-public&grant_type=refresh_token&refresh_token={os.environ["KC_REFRESH_TOKEN"]}'
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
response = requests.request("POST", url, headers=headers, data=payload)
with open('data.json', 'w', encoding='utf-8') as f:
json.dump(response.json(), f, ensure_ascii=False, indent=4)
def run():
while True:
with open('data.json') as f:
json_data = json.load(f)
payload = f'client_id=binder-oauth-client-public&grant_type=refresh_token&refresh_token={json_data["refresh_token"]}'
response = requests.request("POST", url, headers=headers, data=payload)
with open('data.json', 'w', encoding='utf-8') as f:
json.dump(response.json(), f, ensure_ascii=False, indent=4)
time.sleep(120)
if __name__ == "__main__":
run()