Skip to content

Commit

Permalink
Allow missing auth token when a pre-configured client is passed in.
Browse files Browse the repository at this point in the history
  • Loading branch information
led02 committed Dec 20, 2023
1 parent 60ecf7c commit 307d182
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/hermes/commands/deposit/invenio.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,14 @@ def __init__(self, click_ctx: click.Context, ctx: CodeMetaContext, client=None,
self.invenio_context_path = ContextPath.parse(f"deposit.{self.platform_name}")
self.invenio_ctx = None

auth_token = self.click_ctx.params.get("auth_token")
if auth_token is None:
raise DepositionUnauthorizedError("No auth token given for deposition platform")
if client is None:
auth_token = self.click_ctx.params.get("auth_token")
if auth_token is None:
raise DepositionUnauthorizedError("No auth token given for deposition platform")
self.client = self.invenio_client_class(auth_token=auth_token, platform_name=self.platform_name)
else:
self.client = client

self.client = client or self.invenio_client_class(auth_token=auth_token, platform_name=self.platform_name)
self.resolver = resolver or self.invenio_resolver_class(self.client)
self.config = config.get("deposit").get(self.platform_name, {})
self.links = {}
Expand Down

0 comments on commit 307d182

Please sign in to comment.