{"id":20956522,"url":"https://github.com/bluebrain/bbp-token-fetch","last_synced_at":"2025-05-14T05:31:58.979Z","repository":{"id":255487964,"uuid":"851123058","full_name":"BlueBrain/bbp-token-fetch","owner":"BlueBrain","description":"Fetching and automatic refreshing of the Nexus token using Keycloak","archived":false,"fork":false,"pushed_at":"2024-11-01T10:31:31.000Z","size":111,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-13T01:02:59.096Z","etag":null,"topics":["atlas","database"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BlueBrain.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.rst","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.txt","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-02T13:18:26.000Z","updated_at":"2024-11-01T10:29:21.000Z","dependencies_parsed_at":"2024-09-05T19:01:11.577Z","dependency_job_id":"40eecdbf-7098-4748-b49e-914cd9499760","html_url":"https://github.com/BlueBrain/bbp-token-fetch","commit_stats":null,"previous_names":["bluebrain/bbp-token-fetch"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlueBrain%2Fbbp-token-fetch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlueBrain%2Fbbp-token-fetch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlueBrain%2Fbbp-token-fetch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlueBrain%2Fbbp-token-fetch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BlueBrain","download_url":"https://codeload.github.com/BlueBrain/bbp-token-fetch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225277105,"owners_count":17448626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["atlas","database"],"created_at":"2024-11-19T01:26:28.245Z","updated_at":"2024-11-19T01:26:28.935Z","avatar_url":"https://github.com/BlueBrain.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Description\nThis CLI allows the fetching and the automatic refreshing of the Nexus token using Keycloak. \nIts value can be written periodically in a file whose path is given in input or be displayed on the console output as desired.\nThe CLI is based on the class TokenFetcherUser that is in charge of the token fetching and \nrefreshing. If being imported as a library, two public methods of a TokenFetcherUser object makes \npossible to get a fresh Nexus access token and to get its life duration.\n\nFor more information about Nexus, see https://bluebrainnexus.io/\n\n## Install\nClone the repository:\n```\ngit clone https://github.com/BlueBrain/bbp-token-fetch.git\n```\nand install with `pip`:\n```\npip install blue_brain_nexus_token_fetch\n```\nFrom now on, the executable **blue-brain-token-fetch** is in your `PATH`.\n\n## CLI arguments\n- **--username** - [Prompt] Username to request the access token. Default is the username detected by whoami (environmental variable $USER).\n- **--password** - [Prompt] Password to request the access token.\n- **--output / -o** - [Flag] Flag option allowing for 3 distinct outputs:\n  - {not_given} : By default the fetched token will be written in the file located at\n    $HOME/.token_fetch/Token,\n  - {-o/--output} : Providing only the flag will print the token on the console output,\n  - {-o/--output} {PATH}: If a value (argument 'path') is given as a file path, the token\n    will be written in this file location,\nNote: The output file containing the token will have owner read/write access.\n- **path** - [File path] Path to the eventual output token file.\n- **--refresh-period / -rp** - [default 15] Duration of the period between which the token\nwill be written in the file. It can be expressed as number of seconds or by using time unit : '{float}{time unit}'.Available time unit are :\n  - ['s', 'sec', 'secs', 'second', 'seconds'] for seconds,\n  - ['m', 'min', 'mins', 'minute', 'minutes'] for minutes,\n  - ['h', 'hr', 'hrs', 'hour', 'hours'] for hours,\n  - ['d', 'day', 'days'] for days.\nEx: '-rp 30' '-rp 30sec', '-rp 0.5min', '-rp 0.1hour'\n- **--timeout / -to** - \"Duration corresponding to the life span to be applied to the application before it is stopped. It can be expressed as number of seconds or by using time unit : '{float}{time unit}'. Available time unit are :\n  - ['s', 'sec', 'secs', 'second', 'seconds'] for seconds,\n  - ['m', 'min', 'mins', 'minute', 'minutes'] for minutes,\n  - ['h', 'hr', 'hrs', 'hour', 'hours'] for hours,\n  - ['d', 'day', 'days'] for days.\nEx: '-rp 30' '-rp 30sec', '-rp 0.5min', '-rp 0.1hour'\n- **--keycloak-config-file / -kcf** - [File Path] The path to the yaml file containing the configuration to create the keycloak instance. If not provided, it will search in your $HOME directory for a '$HOME/.token_fetch/keycloack_config.yaml' file containing the keycloak configuration.If this file does not exist or the configuration inside is wrong, the configuration will be prompt in the console output and saved in the $HOME directory under the name: '$HOME/.token_fetch/keycloack_config.yaml'.\n\n## Examples\n- Print to the console output a fresh 'access token' continuously :\n```\nblue-brain-token-fetch\n```\n\n- Write every 10 seconds a fresh 'access token' into the token file before exiting after 1 hour:\n```\nblue-brain-token-fetch -o path ./token.txt \\\n              \t       -rp 10s \\\n                       -to 1h \\\n```\nNote: If you want to regain control on the keyboard you can launch the CLI then kill its process then relaunch it in background mode by doing:\n```\nblue-brain-token-fetch\n# ctrl+z\nbg\n```\n- If imported in a script:\n\n  - For regular accounts with credentials `username` and `password`\n  ```\n  my_token_fetcher = TokenFetcherUser(username, password, keycloak_config_file)\n  ```\n  - For service accounts with credentials `client_id` and `client_password` \n  ```\n  my_token_fetcher = TokenFetcherService(client_id, client_password, keycloak_config_file)\n  ```\n  Then you can get an access token and its duration (how long until it expires) with:\n  ```\n  my_access_token = my_token_fetcher.get_access_token() \n  acess_token_duration = my_token_tetcher.get_access_token_duration() \n  ```\n\n## Funding \u0026 Acknowledgment\nThe development of this software was supported by funding to the Blue Brain Project, a \nresearch center of the École polytechnique fédérale de Lausanne (EPFL), from the Swiss \ngovernment’s ETH Board of the Swiss Federal Institutes of Technology.\n\nCopyright © 2021-2024 Blue Brain Project/EPFL\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluebrain%2Fbbp-token-fetch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbluebrain%2Fbbp-token-fetch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluebrain%2Fbbp-token-fetch/lists"}