JoeyDumont
MBS-<really_long_string_that_looks_like_a_hash_of_some_sort>/<computer_hostname>/
MattAccepted Answer
JoeyDumont
# -- Start a requests Session.
session = requests.Session()
# -- Get an access token the API credentials generated in the management
# -- console, and prepare the header for future requests.
response = session.post("https://api.mspbackups.com/api/Provider/Login",json={"UserName": config['mbs_api_auth']['UserName'], "Password": config['mbs_api_auth']['Password']})
json_test = json.loads(response.text)
session.headers = {"Accept": "application/json",
"Authorization": "Bearer {}".format(json_test['access_token'])}
# -- Get the list of users.
response = session.get("https://api.mspbackups.com/api/Users")
user_list = json.loads(response.text)
# -- Determine the user ID from their user account, stored in the email field
# -- for some reason.
for element in user_list:
if element['Email'] == args.user:
print("User {} has ID {}".format(args.user,element['ID']))
Steve Putnam
Thank you for visiting! Please take a moment to register so that you can participate in discussions!