Skip to main content

gh-auth

A simple Python library for web-based GitHub authentication using the device flow.

Installation

pip install gh-auth

Usage

  1. On GitHub, create a GitHub or OAuth app.

  2. In your code, import the authenticate_with_github() function and pass it your app's client ID.

from gh_auth import authenticate_with_github

authenticate_with_github(client_id)

That's it.

When called, the function will prompt users to visit https://github.com/login/device and enter an eight-character code, then continously ping GitHub for a response. Upon sucessful authentication, the function will return a token you can use to interact with the GitHub API via libraries such as PyGithub.

Scopes

If you're using an OAuth app, you'll probably also want to define what scopes you want your app to be granted. Simply pass a list of scopes into the authenticate_with_github() function alongside your client ID, like so:

authenticate_with_github(client_id, scopes=["example_scope", "another_scope"])

See a full list of available OAuth scopes here.

If you're using an OAuth app and don't define any scopes, GitHub will default to granting it read-only access to the public data associated with the account being authenticated and nothing more. (For GitHub apps, scopes are defined on GitHub and can't be changed from this module.)

License

gh-auth's source code is released under the MIT License.

Metadata

Release files for gh-auth 0.1.3

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

Source distribution (sdist)

Source distribution for gh-auth 0.1.3
File Size Uploaded
gh_auth-0.1.3.tar.gz 3.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gh-auth 0.1.3
File Interpreter ABI Platform
gh_auth-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 6.6 kB

Release files / gh_auth-0.1.3.tar.gz

Download URL gh_auth-0.1.3.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
545a4719c7c805e3d15451ac0d788dd2865e63908a7ef78045204ffbf91b5a2d
BLAKE2b-256 checksum
How to use checksums
21f5b9f910d7f1baf409b50da672ad765f6a6c649f4a25a8c08f8e91f3aa58ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.9.0 Windows/10

Release files / gh_auth-0.1.3-py3-none-any.whl

Download URL gh_auth-0.1.3-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a2c9748bae7fa38b53af5889f075345364b25816b8c843c49b014de61248376
BLAKE2b-256 checksum
How to use checksums
defe6db6d3ef4e780c5fa68f1bddf7ae85b55eea58ccc0a1cb23aac40695315f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.9.0 Windows/10

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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