Skip to main content

Oauth2 Client

Python library responsible for managing users authentication using OAUTH 2.0 Client Backend Application strategy (from non web software to web Oauth2 providers)

Repository:

Dependencies:

Installation

Python project

  1. Install requirements, if never done before

1.1. For OS X distributions:

1.1.1. Homebrew

      brew install python3

1.1.2 Port

      sudo port install python36

      sudo port select --set python3 python36

      sudo port install py36-pip
      sudo port select --set pip pip36

1.2. For Linux distributions:

sudo apt-get update
sudo apt-get install python3.9
  1. Make oauth2_xfel_client library available in your python environment

2.1. Install it via pip:

# Install dependencies from local wheels files
pip install . --no-index --find-links ./external_dependencies/

# Install dependencies from the pypi
pip install .

Installing it will place two folders under the current Python installation site-packages folder:

  • oauth2_xfel_client with the sources;

  • oauth2_xfel_client-6.1.1.dist-info/ with Wheels configuration files.

To identify your Python site-packages folder run:

python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"

Usage

To use this project you need to import it:

from oauth2_xfel_client import Oauth2ClientBackend
  1. Connection to the Oauth2Client (MyMdC example):

    from oauth2_xfel_client import Oauth2ClientBackend as Oauth2Client
    
    # Necessary configuration variables to establish a connection
    # Go to https://in.xfel.eu/metadata/oauth/applications to make generate
    # or re-use a Client/Secret tokens from the metadata catalogue.
    user_id = 'PUT_HERE_YOUR_CLIENT_KEY'
    user_secret = 'PUT_HERE_YOUR_SECRET_KEY'
    # Go to https://in.xfel.eu/metadata/users/edit and copy "Contact email"
    user_email = 'luis.maia@xfel.eu'
    
    # URLs for the metadata catalogue
    token_url = 'https://in.xfel.eu/metadata/oauth/token'
    refresh_url = 'https://in.xfel.eu/metadata/oauth/token'
    auth_url = 'https://in.xfel.eu/metadata/oauth/authorize'
    scope = ''
    base_api_url = 'https://in.xfel.eu/metadata/api/'
    
    # Generate the connection
    oauth_client_valid = Oauth2Client(client_id=user_id,
                                      client_secret=user_secret,
                                      scope=scope,
                                      token_url=token_url,
                                      refresh_url=refresh_url,
                                      auth_url=auth_url,
                                      session_token=None,
                                      max_retries=3,
                                      timeout=12,
                                      ssl_verify=True)
  2. Interaction with the oauth2Client:

2.1 Example data_group_types:

current_token = oauth_client_valid.get_session_token()

Development & Testing

When developing, and before commit changes, please validate that:

  1. All tests continue passing successfully (to validate that run pytest):

    # Go to the source code directory
    cd oauth2_xfel_client
    
    # Upgrade package and all its required packages
    pip install . -U --upgrade-strategy eager
    
    # Install test dependencies
    pip install '.[test]' -U --upgrade-strategy eager
    
    # Run all tests using pytest
    pytest
    
    # When running all tests against the standard http application
    OAUTHLIB_INSECURE_TRANSPORT=1 pytest
    
    # Run all tests and get information about coverage for all files inside oauth2_xfel_client package
    pytest --cov oauth2_xfel_client --cov-report term-missing
  2. Code keeps respecting pycodestyle code conventions (to validate that run pycodestyle):

    pycodestyle .
  3. To generate all the wheels files for the dependencies, execute:

    # Generate Wheels to itself and dependencies
    pip wheel --wheel-dir=./external_dependencies .
    pip wheel --wheel-dir=./external_dependencies --find-links=./external_dependencies .
  4. Check that you have the desired dependency versions in external_dependencies folder, since no versions are now set in setup.py.

Registering library on https://pypi.org

To register this python library, the following steps are necessary:

# Install twine
python -m pip install --upgrade twine

# Generates source distribution (.tar.gz) and wheel (.whl) files in the dist/ folder
python setup.py sdist
python setup.py bdist_wheel

# Upload new version .egg and .whl files
twine upload dist/*

# In case a test is necessary, it is possible to test it against test.pypi.org
twine upload --repository-url https://test.pypi.org/legacy/ dist/* --verbose

Metadata

Release files for oauth2-xfel-client 6.1.1

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

Source distribution (sdist)

Source distribution for oauth2-xfel-client 6.1.1
File Size Uploaded Provenance Actions
oauth2_xfel_client-6.1.1.tar.gz 11.9 kB Without provenance Details for oauth2_xfel_client-6.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for oauth2-xfel-client 6.1.1
File Interpreter ABI Platform Actions
oauth2_xfel_client-6.1.1-py3-none-any.whl Python 3 none any Details for oauth2_xfel_client-6.1.1-py3-none-any.whl

Total release size: 21.7 kB

Release files / oauth2_xfel_client-6.1.1.tar.gz

Download URL oauth2_xfel_client-6.1.1.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c547104742873f0f92ad6a96013a3903baba1e221ea0b7c79607b87fd24fc1ef
BLAKE2b-256 checksum
How to use checksums
9e94f4b9eab2d8241fc0e059d392a2b15ce22cd0f8bb8fb5ef6efb9c5b8fcbb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.8

Release files / oauth2_xfel_client-6.1.1-py3-none-any.whl

Download URL oauth2_xfel_client-6.1.1-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a78c26b4dfad7f9575d402ab4cb4798c87f347efa92a4ba5c883dda336f63a8
BLAKE2b-256 checksum
How to use checksums
1546d8a076d2c8cb2442ee819d9a4cf907c37609b7582199e7288103cde164f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.8

Security for oauth2-xfel-client 6.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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