GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - timo-reymann/python-oauth2-cli-auth: Authenticate against OAuth2 Provider in Python CLIs

BranchesTags
Open more actions menu

Latest commit

 

History

210 Commits
210 Commits

Folders and files

NameName
Last commit message
Last commit date
.circleci
.circleci
 
 
.github/images
.github/images
 
 
.idea
.idea
 
 
docs-theme
docs-theme
 
 
oauth2_cli_auth
oauth2_cli_auth
 
 
pydoctor-theme @ 45330e6
pydoctor-theme @ 45330e6
 
 
.gitignore
.gitignore
 
 
.gitmodules
.gitmodules
 
 
.pre-commit-config.yaml
.pre-commit-config.yaml
 
 
.releaserc.json
.releaserc.json
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CONTRIBUTIND.md
CONTRIBUTIND.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
codecov.yaml
codecov.yaml
 
 
poetry.lock
poetry.lock
 
 
pyproject.toml
pyproject.toml
 
 
renovate.json
renovate.json
 
 
sonar-project.properties
sonar-project.properties
 
 

Repository files navigation

oauth2-cli-auth

LICENSE CircleCI GitHub Release PyPI version PyPI - Downloads codecov Quality Gate Status Code Smells Maintainability Rating Security Rating Renovate pre-commit


Authenticate against OAuth2 Provider in Python CLIs

Features

  • Simple
  • Fancy callback page

Requirements

  • Python 3.9+

Installation

pip install oauth2-cli-auth

Usage

Simple with OIDC well known configuration endpoint

This should work for every provider supporting OIDC e.g. gitlab.com:

from oauth2_cli_auth import get_access_token_with_browser_open, OAuth2ClientInfo

client_info = OAuth2ClientInfo.from_oidc_endpoint(
    "https://gitlab.com/.well-known/openid-configuration",
    client_id="my-client-id",
    scopes=["openid"]
)

try:
    token = get_access_token_with_browser_open(client_info)
    print(f"Obtained token '{token}'")
except ValueError:
    print("Failed to obtain token")

Simple with manual endpoint specification

The following should work for almost all use cases, for rest please check the lib docs.

from oauth2_cli_auth import get_access_token_with_browser_open, OAuth2ClientInfo

client_info = OAuth2ClientInfo(
    client_id="<clientId>",
    authorization_url="<authorizeUrl>",
    token_url="<TokenUrl>",
    scopes=["scopeA", "scopeB"]
)

try:
    token = get_access_token_with_browser_open(client_info)
    print(f"Obtained token '{token}'")
except ValueError:
    print("Failed to obtain token")

Motivation

Building oauth2 integration for Python apps come quite handy, especially with Gitlab integration etc.

It is a bit cumbersome to do it manually everytime, existing solutions are way to overkill to put on this problem. So I created this small library without any dependencies besides the python standard library.

Documentation

  • Library documentation

Contributing

I love your input! I want to make contributing to this project as easy and transparent as possible, whether it's:

  • Reporting a bug
  • Discussing the current state of the configuration
  • Submitting a fix
  • Proposing new features
  • Becoming a maintainer

To get started please read the Contribution Guidelines.

Development

Requirements

  • Python 3.9+
  • pre-commit
  • Poetry

Test

poetry run pytest .

Build

poetry install

About

Authenticate against OAuth2 Provider in Python CLIs

pypi.org/project/oauth2-cli-auth/

Topics

clioauth2pippython

Resources

Readme
MIT license

Contributing

Contributing

Security policy

Security policy
Activity

Stars

19 stars

Watchers

1 watching

Forks

4 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.