File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 11import datetime
22import time
3+ import requests
4+
5+
6+ def auth (email , password , baseURL , verify ):
7+ """Authenticate the user to the DSpace API."""
8+ data = {'email' : email , 'password' : password }
9+ header = {'content-type' : 'application/json' ,
10+ 'accept' : 'application/json' }
11+ session = requests .post (baseURL + '/rest/login' , headers = header ,
12+ verify = verify ,
13+ params = data ).cookies ['JSESSIONID' ]
14+ cookies = {'JSESSIONID' : session }
15+ return (cookies , header )
16+
17+
18+ def authConfirm (cookies , baseURL , header , verify ):
19+ """Confirm user was successfully authenticated to the DSpace API."""
20+ status = requests .get (baseURL + '/rest/status' , headers = header ,
21+ cookies = cookies , verify = verify ).json ()
22+ uName = status ['fullname' ]
23+ authEmail = status ['email' ]
24+ print ('authenticated' , uName , authEmail )
25+ return (uName , authEmail )
326
427
528def elapsedTime (startTime , label ):
You can’t perform that action at this time.
0 commit comments