Skip to content

Instantly share code, notes, and snippets.

@Aldaviva
Created September 30, 2015 22:24
Show Gist options
  • Save Aldaviva/fe85b1cb8a3e020f4ba9 to your computer and use it in GitHub Desktop.
Save Aldaviva/fe85b1cb8a3e020f4ba9 to your computer and use it in GitHub Desktop.
Example of a simple Python client for the Blue Jeans Relay API, including authentication
import getpass
import base64
import requests
print "How Many Endpoints Are In Your Relay Enterprise?\n"
username = raw_input('username: ')
password = getpass.getpass('password: ')
basicAuthValue = base64.standard_b64encode(username + ":" + password)
print '\nRequest headers:\n\tAuthorization: Basic '+basicAuthValue
url = 'https://relay.bluejeans.com/api/endpoints'
headers = { 'Authorization': 'Basic '+basicAuthValue }
r = requests.get(url, headers=headers)
print "\nResponse:\n\tStatus code: "+str(r.status_code)
if r.status_code == requests.codes.ok:
print "\nYour Relay Enterprise has "+str(len(r.json()))+" Endpoints."
@Aldaviva
Copy link
Author

Tested on Python 2.7.9.
Requires Requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment