def login():
# Import in here for performance reasons
import webbrowser
# TODO: use Oauth and a local webserver: https://community.auth0.com/questions/6501/authenticating-an-installed-cli-with-oidc-and-a-th
url = api.app_url + '/profile'
# TODO: google cloud SDK check_browser.py
launched = webbrowser.open_new_tab(url)
if launched:
click.echo(
'Opening [{0}] in a new tab in your default browser.'.format(url))
else:
click.echo("You can find your API keys here: {0}".format(url))
key = click.prompt("{warning} Paste an API key from your profile".format(
warning=click.style("Not authenticated!", fg="red")),
value_proc=lambda x: x.strip())
if key:
# TODO: get the username here...
# username = api.viewer().get('entity', 'models')
write_netrc(api.api_url, "user", key)
评论列表
文章目录