-
Notifications
You must be signed in to change notification settings - Fork 112
DCOS-1521 Fix OAuth wording #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,13 @@ | ||
| import json | ||
| import os | ||
| import sys | ||
| import uuid | ||
|
|
||
| import pkg_resources | ||
| import toml | ||
| from dcos import config, constants, emitting, errors, http, jsonitem, util | ||
| from dcos.errors import DCOSException | ||
| from six import iteritems, moves | ||
| from six import iteritems | ||
|
|
||
| from oauth2client import client | ||
|
|
||
|
|
@@ -69,29 +70,31 @@ def _run(flow): | |
| :rtype: dict | ||
| """ | ||
|
|
||
| auth_url = flow.step1_get_authorize_url() | ||
| message = """Thank you for installing the Mesosphere DCOS CLI. | ||
| Please log in with your Mesosphere Account by pasting | ||
| the following URL into your browser to continue.""" | ||
| emitter.publish(errors.DefaultError( | ||
| '{message}\n\n {url}\n\n'.format(message=message, | ||
| url=auth_url,))) | ||
| emitter.publish( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we haven't been using named parameters in string interpolation. I know you didn't write this, but can you change it?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, why are we printing this to stderr?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A principal that we try to keep in the dcos cli is that stdout should have a predictable output that is pipe-able to a program. E.g. grep, jq, etc. Let say that you want to:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Done. |
||
| errors.DefaultError( | ||
| '\n\n\n{}\n\n {}\n\n'.format( | ||
| 'Go to the following link in your browser:', | ||
| flow.step1_get_authorize_url()))) | ||
|
|
||
| code = moves.input('Please enter Mesosphere verification code: ').strip() | ||
This comment was marked as off-topic.
Sorry, something went wrong. |
||
| sys.stderr.write('Enter verification code: ') | ||
| code = sys.stdin.readline().strip() | ||
| if not code: | ||
| email = moves.input('Skipping authentication.' | ||
| ' Please enter email address:').strip() | ||
| sys.stderr.write('Skipping authentication.\nEnter email address: ') | ||
|
|
||
| email = sys.stdin.readline().strip() | ||
| if not email: | ||
| emitter.publish(errors.DefaultError('Skipping email input,' | ||
| ' using anonymous id:')) | ||
| emitter.publish( | ||
| errors.DefaultError( | ||
| 'Skipping email input.')) | ||
| email = str(uuid.uuid1()) | ||
|
|
||
| return {CORE_EMAIL_KEY: email} | ||
|
|
||
| return make_oauth_request(code, flow) | ||
|
|
||
|
|
||
| def check_if_user_authenticated(): | ||
| """ check if user is authenticated already | ||
| """Check if user is authenticated already | ||
|
|
||
| :returns user auth status | ||
| :rtype: boolean | ||
|
|
@@ -102,7 +105,7 @@ def check_if_user_authenticated(): | |
|
|
||
|
|
||
| def force_auth(): | ||
| """ Make user authentication process | ||
| """Make user authentication process | ||
|
|
||
| :returns authentication process status | ||
| :rtype: boolean | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what was wrong with moves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were using for
six.moves.input. That function takes a prompt string that gets printed to stdout. This is not correct because the user could be callingdcos marathon app showwhich prints a JSON object. A principal that we try to keep in the dcos cli is that stdout should have a predictable output that is pipe-able to a program. E.g. grep, jq, etc.