Commit 77b1dfb3 authored by Ryan Petrello's avatar Ryan Petrello

add configurable scope for `tower-cli login`

parent 0f3ecec1
......@@ -236,12 +236,12 @@ class Client(Session):
# Sanity check: Did we fail to authenticate properly?
# If so, fail out now; this is always a failure.
if r.status_code == 401:
raise exc.AuthError('Invalid Tower authentication credentials.')
raise exc.AuthError('Invalid Tower authentication credentials (HTTP 401).')
# Sanity check: Did we get a forbidden response, which means that
# the user isn't allowed to do this? Report that.
if r.status_code == 403:
raise exc.Forbidden("You don't have permission to do that.")
raise exc.Forbidden("You don't have permission to do that (HTTP 403).")
# Sanity check: Did we get a 404 response?
# Requests with primary keys will return a 404 if there is no response,
......@@ -212,11 +212,12 @@ def config(key=None, value=None, scope='user', global_=False, unset=False):
@click.argument('username', required=True)
@click.option('--password', required=True, prompt=True, hide_input=True)
@click.option('--scope', required=False, default='write',
type=click.Choice(['read', 'write']))
@click.option('-v', '--verbose', default=None,
help='Show information about requests being made.', is_flag=True,
required=False, callback=_apply_runtime_setting, is_eager=True)
def login(username, password):
def login(username, password, scope, verbose):
Retrieves and stores an OAuth2 personal auth token.
......@@ -231,7 +232,7 @@ def login(username, password):
HTTPBasicAuth(username, password)(req)
r =
data={"description": "Tower CLI", "application": None, "scope": "read"},
data={"description": "Tower CLI", "application": None, "scope": scope},
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment