Skip to content
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

Fix: do not try to authenticate when requesting help (#4) #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bananas_cli/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def wait_for_code():
raise Exit


async def authenticate(session, client_id):
async def authenticate(session):
config_folder = click.get_app_dir("bananas-cli")
os.makedirs(config_folder, exist_ok=True)
token_filename = config_folder + "/token"
Expand All @@ -104,7 +104,7 @@ async def authenticate(session, client_id):
"audience=github&"
"redirect_uri=http%3A%2F%2Flocalhost%3A3977%2F&"
"response_type=code&"
f"client_id={client_id}&"
f"client_id={Authenticate.client_id}&"
f"code_challenge={code_challenge}&"
"code_challenge_method=S256"
)
Expand Down
4 changes: 2 additions & 2 deletions bananas_cli/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import click
import logging

from .authentication import authenticate
from .authentication import Authenticate
from .helpers import task
from .session import Session

Expand Down Expand Up @@ -43,7 +43,7 @@ async def cli(ctx, api_url, tus_url, client_id):
ctx.obj = session

await session.start()
await authenticate(session, client_id)
Authenticate.client_id = client_id


@task
Expand Down
3 changes: 3 additions & 0 deletions bananas_cli/commands/list_self.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
)
from ..exceptions import Exit
from ..helpers import task
from ..authentication import authenticate

log = logging.getLogger(__name__)

Expand All @@ -14,6 +15,8 @@
@pass_session
@task
async def list_self(session):
await authenticate(session)

status, data = await session.get("/package/self")
if status != 200:
log.error(f"Server returned invalid status code {status}: {data}")
Expand Down
3 changes: 3 additions & 0 deletions bananas_cli/commands/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from ..enums import License
from ..exceptions import Exit
from ..helpers import task
from ..authentication import authenticate

log = logging.getLogger(__name__)

Expand All @@ -28,6 +29,8 @@ def show_validation_errors(data):
@pass_session
@task
async def upload(session, version, name, description, url, license, files):
await authenticate(session)

parts = files[0].split("/")[:-1]
for filename in files:
check_parts = filename.split("/")
Expand Down