-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_sessionID.py
More file actions
40 lines (29 loc) · 1012 Bytes
/
gen_sessionID.py
File metadata and controls
40 lines (29 loc) · 1012 Bytes
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
import requests
import urllib3
import time
import json
import pickle
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) #ignore cert stuff. this is an internal job so its ok.
host = ""
## New login method ----
api_login = f'https://{host}/rest/v1/login'
api_headers = {
'Content-Type': 'application/json'
}
login_payload = json.dumps({
"username": username,
"password": userpass,
"useOIDC": False
})
login_response = requests.request("POST",
api_login,
headers=api_headers,
data=login_payload,
verify=False
)
api_headers['Cookie'] = 'sessionID={0}'.format(
login_response.cookies.get('sessionID'))
print(api_headers)
print("Logged in..")
pickle.dump( api_headers, open( "session/aisys_sessionLogin.p", "wb"))
print("AI Systems Session Saved, you do not need to auth for another 12 hours!")