Created
September 30, 2015 22:24
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested on Python 2.7.9.
Requires Requests.