Metadata-Version: 2.1
Name: helper-auth
Version: 0.1.0
Summary: Requests authentication using existing helpers
Home-page: https://github.com/mportesdev/helper-auth
License: MIT
Author: Michal Porteš
Author-email: michalportes1@gmail.com
Requires-Python: >=3.7,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: requests (>=2,<3)
Description-Content-Type: text/markdown

# Installation

```
pip install helper-auth
```

# Usage

Objects of the `HelperAuth` class are intended to be used as custom
authentication handlers as per the
[Requests documentation](https://requests.readthedocs.io/en/latest/user/authentication/#new-forms-of-authentication).


## Default scenario

Suppose you have an existing GitHub personal access token, and a
[Git credential helper](https://git-scm.com/docs/gitcredentials#_custom_helpers)
already set up for Git to authenticate to GitHub using this token as
the password. This helper is named `git-credential-github` and prints
the following to standard output:

```
username=your_github_username
password=your_github_token
```

You want to use the same token to make GitHub API calls in Python with
the help of the Requests library. The API expects a
`token your_github_token` string as the value of
your request's `Authorization` header.

You can use `HelperAuth` with its default settings:

```python
import requests
from helper_auth import HelperAuth

headers = {'Accept': 'application/vnd.github+json'}
auth = HelperAuth('git-credential-github')

response = requests.get(
    'https://api.github.com/user/repos',
    headers=headers,
    auth=auth,
)
```

