What are basic_auth_username and basic_auth_password in apiv2 examples?

25 views
Skip to first unread message

ronald....@seagate.com

unread,
Aug 15, 2016, 5:05:53 PM8/15/16
to scalr-...@googlegroups.com
I am trying to understand the code in the python examples for apiv2  (https://github.com/scalr-tutorials/apiv2-examples/tree/master/python). I see in the credentials-sample.json file (https://github.com/scalr-tutorials/apiv2-examples/blob/master/python/credentials-sample.json) there are the url, key_id, key_secret and env_id, but there is no username or password. Then in the main.py file (https://github.com/scalr-tutorials/apiv2-examples/blob/master/python/main.py) it seems to be reading a username and password from the credentials file. So what are the username and password in this case and should they be in the creds file? I am wondering if the APIv2 key is tied to a specific username/password or if a specific username/password should be used. 

credentials-sample.json:

{
    "api_url": "https://my.scalr.com",
    "api_key_id": "API Key ID goes here",
    "api_key_secret": "API Key Secret goes here",
    "env_id": "Environment ID goes here"
}

part of main.py:

def main(credentials_file, scenario, log_level=logging.INFO):
    # Setup credentials
    with open(credentials_file) as f:
        creds = json.load(f)
        api_url, api_key_id, api_key_secret, env_id, basic_auth_username, basic_auth_password = \
                [creds.get(k, "") for k in ["api_url", "api_key_id", "api_key_secret", "env_id", "basic_auth_username", "basic_auth_password"]]

    client = ScalrApiClient(api_url.rstrip("/"), api_key_id, api_key_secret)
    client.logger.setLevel(log_level)
    client.session.auth = requests.auth.HTTPBasicAuth(basic_auth_username, basic_auth_password)



Thanks!
Ron

Marc O'Brien

unread,
Aug 16, 2016, 1:19:06 PM8/16/16
to scalr-...@googlegroups.com
Hi Ron,

Thank you for bringing this to our attention.  The basic_auth_username and basic_auth_password values you were seeing were actually a relic of the past.  As of today, these are removed from our examples.

As you noted, the API key is tied to a specific account.  More details on APIv2 auth are available here.

Cheers,
Wm. Marc O'Brien
Scalr Technical Support
Reply all
Reply to author
Forward
0 new messages