Requests authentication using existing helpers
Project description
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.
Default scenario
Suppose you have an existing GitHub personal access token, and a
Git credential helper
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:
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,
)
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
Hashes for helper_auth-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fc88f79b6f3c6f00342f43bb04d02c76a0249ba7b60d0f5bab8997760ec41a9 |
|
MD5 | 36bf6b28ba9bb65108000683e0fb4cba |
|
BLAKE2b-256 | 8f740b7c8dcd6fe0d6fc6a03befd0c18c02ae23ede73962d8b1e652eb2507cf9 |