How to get an API token and authorization in REST with Python
This guide shows how to log in to an application using REST and get an API token to authenticate yourself in Python.
If you are using Postman or GpsGate REST API GUI, please read how to use REST API with Postman and GpsGate REST API GUI.
Prerequisites
Once you get the token as upper guide, we could put it on a variable for example tk.
Authorizing use of the token
To send an authorization request to GpsGate REST API, you need to select the GET method with an authorization key (the token obtained previously), as in the sample code below.
Sample of loading a user list with REST:
url1 = "http://192.168.0.34/comGpsGate/api/v.1/applications/40/users?FromIndex=0&PageSize=1000"
headers = {
"accept" : "application/json",
"Authorization": str(tk)
}
resp = requests.get(url1, headers=headers)
if resp.status_code != 200:
print('error: ' + str(resp.status_code))
else:
print('User List Loaded Successfully')