diff --git a/README.md b/README.md index 75050983f90d9f1eeeda346da719222bed854a1d..019dc8fe276fc0820b7a357c59553b68ad1dbd3a 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,8 @@ funkwhale --help # get help on a specific command funkwhale tracks ls --help -# get login -funkwhale -H https://demo.funkwhale.audio login # credentials are demo and demo on this server +# get login - You need to create an application in your Funkwhale-settings. Then you need to provide the client-id and the client-secret of that application here +funkwhale -H https://demo.funkwhale.audio login # Store the server URL to avoid specifying it on the CLI echo "FUNKWHALE_SERVER_URL=https://demo.funkwhale.audio" >> .env diff --git a/funkwhale_cli/api.py b/funkwhale_cli/api.py index a594744d7a2643302de3d92807fd5120e03ae2e2..c0dc16a033012cb84f5a7d6c6ee28be44a6630c8 100644 --- a/funkwhale_cli/api.py +++ b/funkwhale_cli/api.py @@ -47,18 +47,6 @@ def clean_nodeinfo(data): return result.data -async def get_jwt_token(session, url, username, password): - url = f"{url}/api/v1/token/" - response = await session.post( - url, data={"username": username, "password": password} - ) - if response.status == 400: - raise exceptions.AuthenticationError( - "Unable to log in with provided credentials" - ) - return (await response.json())["token"] - - async def get_oauth_token(session, url, client_id, client_secret): args = {"response_type": "code", "redirect_uri": "urn:ietf:wg:oauth:2.0:oob", "client_id": client_id, "client_secret": client_secret, "scope": "read write"} diff --git a/funkwhale_cli/cli/auth.py b/funkwhale_cli/cli/auth.py index 64a0c22b31c9fe8d7b34a87f33c92889f91485a8..fa070cecc808c0370ba62efca4c72102af1c90a7 100644 --- a/funkwhale_cli/cli/auth.py +++ b/funkwhale_cli/cli/auth.py @@ -67,34 +67,6 @@ def init_keyring(): # /end of hack -@base.cli.command() -@click.option("-u", "--username", envvar="FUNKWHALE_USERNAME", prompt=True) -@click.option( - "-p", "--password", envvar="FUNKWHALE_PASSWORD", prompt=True, hide_input=True -) -@click.pass_context -@base.async_command -async def login(ctx, username, password): - async with api.get_session() as session: - token = await api.get_jwt_token( - session, ctx.obj["SERVER_URL"], username=username, password=password - ) - - try: - keyring.set_password(ctx.obj["SERVER_URL"], "_", token) - except ValueError as e: - raise click.ClickException( - "Error while retrieving password from keyring: {}. Your password may be incorrect.".format( - e.args[0] - ) - ) - except Exception as e: - raise click.ClickException( - "Error while retrieving password from keyring: {}".format(e.args[0]) - ) - click.echo("Login successfull!") - - @base.cli.command() @click.option("-i", "--client-id", envvar="FUNKWHALE_CLIENT_ID", prompt=True) @click.option( @@ -102,7 +74,7 @@ async def login(ctx, username, password): ) @click.pass_context @base.async_command -async def login_oauth(ctx, client_id, client_secret): +async def login(ctx, client_id, client_secret): async with api.get_session() as session: access_token, refresh_token = await api.get_oauth_token( session, ctx.obj["SERVER_URL"], client_id=client_id, client_secret=client_secret