Skip to main content

Requests authentication using existing helpers

Project description

helper-auth on PyPI

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

helper_auth-0.2.0.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

helper_auth-0.2.0-py3-none-any.whl (3.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page