Skip to main content

Git Credentials

Simple small library to provide an interface around the git credential Git command. No dependencies but git must in the PATH.

Example

from git_credentials import GitCredentials, GitCredentialDescription, GitCredentialError, GitCredentialNotStoredError

def test_creds(user, pw):
    ...

def ask_for_creds():
    ...

cred = GitCredentials("/path/to/repo")

try:
    response = cred.fill(GitCredentialDescription(
        protocol="https",
        host="example.com",
        path="/"
    ))
    print(f"Request was successful. Host: {response.host}, User: {response.username}, Password: {response.password}")
    # Test the credentials
    if test_creds(response.username, response.password):
        # Tell Git the credentials are good.
        cred.approve(response)
    else:
        # Otherwise tell it to reject them.
        cred.reject(response)
except GitCredentialNotStoredError:
    print("Did not know the PW :(")
    # Ask user for PW. You can store it then (after testing it) using approve:
    (user, pw) = ask_for_creds()
    if test_creds(user, pw):
        # Tell Git the credentials are good.
        cred.approve(GitCredentialDescription(
            protocol="https",
            host="example.com",
            path="/",
            username=user,
            password=pw
        ))
except GitCredentialError:
    # Another misc. error. GitCredentialNotStoredError subclasses this.
    raise

Metadata

Release files for git-credentials 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for git-credentials 1.0.0
File Interpreter ABI Platform Actions
git_credentials-1.0.0-py3-none-any.whl Python 3 none any Details for git_credentials-1.0.0-py3-none-any.whl

Release files / git_credentials-1.0.0-py3-none-any.whl

Download URL git_credentials-1.0.0-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
38440ad0e84f53e6b0eacc1c46e3ee84d5e6daff4353ffc8ee0c2e3e770f4891
BLAKE2b-256 checksum
How to use checksums
13801c84474607459f314fe8f9390e6793f81b1cf7c78b6d9d2aa41befdb19b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Security for git-credentials 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page