MCPcopy Create free account
hub / github.com/Sygil-Dev/sygil-webui / cli_request_api_key

Function cli_request_api_key

scripts/hydrus_api/utils.py:44–70  ·  view source on GitHub ↗
(
    name: str,
    permissions: abc.Iterable[T.Union[int, Permission]],
    verify: bool = True,
    exact: bool = False,
    api_url: str = DEFAULT_API_URL,
)

Source from the content-addressed store, hash-verified

42
43
44def cli_request_api_key(
45 name: str,
46 permissions: abc.Iterable[T.Union[int, Permission]],
47 verify: bool = True,
48 exact: bool = False,
49 api_url: str = DEFAULT_API_URL,
50) -> str:
51 while True:
52 input(
53 'Navigate to "services->review services->local->client api" in the Hydrus client and click "add->from api '
54 'request". Then press enter to continue...'
55 )
56 access_key = Client(api_url=api_url).request_new_permissions(name, permissions)
57 input(
58 "Press OK and then apply in the Hydrus client dialog. Then press enter to continue..."
59 )
60
61 client = Client(access_key, api_url)
62 if verify and not verify_permissions(client, permissions, exact):
63 granted = client.verify_access_key()["basic_permissions"]
64 print(
65 f"The granted permissions ({granted}) differ from the requested permissions ({permissions}), please "
66 "grant all requested permissions."
67 )
68 continue
69
70 return access_key
71
72
73def parse_hydrus_metadata(

Callers

nothing calls this directly

Calls 4

verify_access_keyMethod · 0.95
ClientClass · 0.90
verify_permissionsFunction · 0.85

Tested by

no test coverage detected