Skip to main content

A simple Python library for web-based GitHub authentication.

Project description

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.

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

gh_auth-0.1.3.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gh_auth-0.1.3-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file gh_auth-0.1.3.tar.gz.

File metadata

  • Download URL: gh_auth-0.1.3.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.0 Windows/10

File hashes

Hashes for gh_auth-0.1.3.tar.gz
Algorithm Hash digest
SHA256 545a4719c7c805e3d15451ac0d788dd2865e63908a7ef78045204ffbf91b5a2d
MD5 038331d98ef6ad1ad9ef3393d158c087
BLAKE2b-256 21f5b9f910d7f1baf409b50da672ad765f6a6c649f4a25a8c08f8e91f3aa58ed

See more details on using hashes here.

File details

Details for the file gh_auth-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: gh_auth-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.0 Windows/10

File hashes

Hashes for gh_auth-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0a2c9748bae7fa38b53af5889f075345364b25816b8c843c49b014de61248376
MD5 9642d3ade045fc5edd54bf6f9cd6bac1
BLAKE2b-256 defe6db6d3ef4e780c5fa68f1bddf7ae85b55eea58ccc0a1cb23aac40695315f

See more details on using hashes here.

Supported by

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