Skip to main content

A Python library for performing OAuth login to a Girder 4 (Django) server.

Project description

girder-cli-oauth-client

A Python library for performing OAuth login to a Girder 4 (Django) server.

Description

This provides support for authenticating with Girder 4 servers, using the OAuth2.0 Authorization Code Grant with PKCE flow and out-of-band redirection.

Usage

  • Install the library:

    pip install girder-cli-oauth-client
    
  • Instantiate an OauthClient with your application-specific configuration:

    from girder_cli_oauth_client import GirderCliOAuthClient
    
    oauth_client = GirderCliOAuthClient(
        'http://localhost:8000/oauth/',
        '1ohsuyWIx9fEsJhmAH2AWGNUqd8Wsd7LHyongtVy',
        'my_oauth_application',
    )
    
  • Call login when it's time to start a login flow:

    oauth_client.login()  # open the browser to login and wait for a code
    
  • At the start of every application start, unconditionally call maybe_restore_login, to attempt to restore a login state; this will no-op if no login is present.

    oauth_client.maybe_restore_login()
    
  • Include these headers with every API request:

    requests.get('http://localhost:8000/api/users/me', headers=oauth_client.auth_headers)
    
  • Call logout to clear any active login:

    oauth_client.logout()
    

Example app

This repository comes bundled with an example application. Run it with:

git clone https://github.com/girder/girder-cli-oauth-client.git
pip install -e '.[dev]'
cd example
python cli.py login
python cli.py me

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

girder-cli-oauth-client-0.0.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

girder_cli_oauth_client-0.0.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file girder-cli-oauth-client-0.0.0.tar.gz.

File metadata

  • Download URL: girder-cli-oauth-client-0.0.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for girder-cli-oauth-client-0.0.0.tar.gz
Algorithm Hash digest
SHA256 05352c9e4e6cce4f80e31a6b7ace51de8f71efd01e010d6ed0b25139055cfc89
MD5 3825786420069ba6ac67a5b6900f4be1
BLAKE2b-256 5e4260f435d80698a9f4d6d38064fdafe2d006972e1b8d3eccbc62febd748077

See more details on using hashes here.

File details

Details for the file girder_cli_oauth_client-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: girder_cli_oauth_client-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for girder_cli_oauth_client-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cbaa84289ca3873b31d3f4064d5d98394967f317ab402f6ddad7e11ef7991038
MD5 5ce289d46e11ef7a2a3fcb59ef13ec8b
BLAKE2b-256 e54265ab4d3e81641bcf50afcaa7b3f01d5705fe14f36388bc693e0933f2d344

See more details on using hashes here.

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