Look up GitHub tokens from various sources
Project description
Kokomikke
Kokomikke (koh•koh•mi•ke) is a Python library that looks up GitHub access tokens from various sources.
Installation
pip install kokomikke
Usage
Basic usage is as simple as:
import kokomikke
token = kokomikke.search()
By default, this will look for a GitHub token in the following locations, in order, returning as soon as one is found:
- The
GITHUB_API_TOKENenvironment variable - The
GITHUB_TOKENenvironment variable - The
GH_TOKENenvironment variable - The
GITHUB_PATenvironment variable - The
GH_PATenvironment variable - GitHub CLI via
gh auth token - GitHub CLI via
hosts.yml
If no token is found, kokomikke.search() will return None.
Sources
In order to search for token, Kokomikke needs sources. A source is an object of a class that inherits from
kokomikke.sources.Source and implements the lookup() method:
from kokomikke.sources import Source
class MySource(Source):
def lookup(self) -> str | None:
# lookup logic goes here
Kokomikke comes with the following sources built-in:
kokomikke.sources.EnvironmentVariableSource
Searches a list of environment variables, in order, for a non-empty value.
It takes the following arguments:
variables(list[str], keyword-only, default: [GITHUB_API_TOKEN,GITHUB_TOKEN,GH_TOKEN,GITHUB_PAT,GH_PAT]): The variables to search.
kokomikke.sources.GitHubCLISource
Runs gh auth token and, if there is no error, returns its output.
It takes the following arguments:
hostname(str, keyword-only, default:github.com): The hostname of the GitHub instance to get a token for.
kokomikke.sources.GitHubCLIYamlSource
Reads GitHub CLI's hosts.yml file and returns a token if one is present.
It takes the following arguments:
hostname(str, keyword-only, default:github.com): The hostname of the GitHub instance to get a token for.
kokomikke.sources.GitSource
Calls git credential fill and returns a token if one is present
in the output.
It takes the following arguments:
hostname(str, keyword-only, default:github.com): The hostname of the GitHub instance to get a token for.
kokomikke.sources.CommandSource
Runs an arbitrary command and, if there is no error, returns its output.
It takes the folowing arguments:
- command: (
list, keyword-only): Command arguments.
kokomikke.search() takes an optional sources argument, which expects a list of sources, each of which will
be evaluated in order. For example, to first look for a token via gh auth token, but fall back to pass
if that fails:
import kokomikke
from kokomikke.sources import CommandSource, GitHubCLISource
pass_source = CommandSource(command=["pass", "github.com/mona"])
token = kokomikke.search([GitHubCLISource, pass_source])
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kokomikke-0.1.3.tar.gz.
File metadata
- Download URL: kokomikke-0.1.3.tar.gz
- Upload date:
- Size: 24.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8b29f939b9b9c3de7ad7c5a60c9e03330bc29b993d57de48b52ac6c6be5bafe
|
|
| MD5 |
21e2675846287d545950e3aebad21b99
|
|
| BLAKE2b-256 |
f025dfaee41b2721547c87feca696bec6da8f4b9bab33142ff706f69a8d659f4
|
Provenance
The following attestation bundles were made for kokomikke-0.1.3.tar.gz:
Publisher:
release.yml on celsiusnarhwal/kokomikke
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kokomikke-0.1.3.tar.gz -
Subject digest:
a8b29f939b9b9c3de7ad7c5a60c9e03330bc29b993d57de48b52ac6c6be5bafe - Sigstore transparency entry: 1838804293
- Sigstore integration time:
-
Permalink:
celsiusnarhwal/kokomikke@649590501ffed640609a638f507ecb55e867e69a -
Branch / Tag:
refs/tags/0.1.3 - Owner: https://github.com/celsiusnarhwal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@649590501ffed640609a638f507ecb55e867e69a -
Trigger Event:
release
-
Statement type:
File details
Details for the file kokomikke-0.1.3-py3-none-any.whl.
File metadata
- Download URL: kokomikke-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ee25a9e970d7e73ee83df8b944e2c8e2c24e1e930bbff1a124d3a1ef49f5e21
|
|
| MD5 |
e9e4ad550b7140531fdeb55531ed7074
|
|
| BLAKE2b-256 |
386563df084627e358392a3be10b3de382d34839b32ae3a86a87b15a07887d13
|
Provenance
The following attestation bundles were made for kokomikke-0.1.3-py3-none-any.whl:
Publisher:
release.yml on celsiusnarhwal/kokomikke
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kokomikke-0.1.3-py3-none-any.whl -
Subject digest:
3ee25a9e970d7e73ee83df8b944e2c8e2c24e1e930bbff1a124d3a1ef49f5e21 - Sigstore transparency entry: 1838804376
- Sigstore integration time:
-
Permalink:
celsiusnarhwal/kokomikke@649590501ffed640609a638f507ecb55e867e69a -
Branch / Tag:
refs/tags/0.1.3 - Owner: https://github.com/celsiusnarhwal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@649590501ffed640609a638f507ecb55e867e69a -
Trigger Event:
release
-
Statement type: