Skip to content

Instantly share code, notes, and snippets.

@jo-migo
Last active September 27, 2018 17:42
Show Gist options
  • Select an option

  • Save jo-migo/27bcaa49b8f9986a0b45f2ed8583c21c to your computer and use it in GitHub Desktop.

Select an option

Save jo-migo/27bcaa49b8f9986a0b45f2ed8583c21c to your computer and use it in GitHub Desktop.
import requests
import sys
username, password, api_path = sys.argv[1], sys.argv[2], sys.argv[3]
payload = {'username': username, 'password': password}
API_URL = 'https://api.lotame.com/2/'
AUTH_URL = 'https://crowdcontrol.lotame.com/auth/v1/tickets'
try:
ticket_location = requests.post(AUTH_URL, data=payload).headers['location']
except KeyError:
print('BAD username/password')
print(ticket_location)
service_call = API_URL + api_path
payload = {'service': service_call}
service_ticket = requests.post(ticket_location, data=payload).text
# Use proper character to append ticket, depending on endpoint
if '?' in api_path:
full_url = service_call + '&ticket=' + service_ticket
else:
full_url = service_call + '?ticket=' + service_ticket
response = requests.get(full_url)
print(response.json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment