Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

git-credentials

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git-credentials

Simple library to interact with Git Credentials

  • 1.0.0
  • PyPI
  • Socket score

Maintainers
1

Git Credentials

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

Example

.. code-block:: python

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

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc