Python OAUTH 2.0 Client used for Backend Application strategy login against European XFEL Web Applications
Project description
Small 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:
oauthlib (https://pypi-hypernode.com/pypi/oauthlib)
requests (https://github.com/kennethreitz/requests)
requests-oauthlib (https://github.com/requests/requests-oauthlib)
Installation
Python project
Install requirements, if never done before
1.1. For OS X distributions:
sudo port install python35 sudo port sudo port select --set python3 python35 sudo port install py35-pip sudo port select --set pip pip351.2. For Linux distributions:
sudo apt-get update sudo apt-get install python3.5
Make oauth2_xfel_client library available in your python environment
Install it via pip:
# Install dependencies from local wheels files pip install --no-index --upgrade --find-links ./external_dependencies/ . # Install dependencies from the pypi pip install .
Running this command 2 folders are generated under the current Python installation site-packages folder:
oauth2_xfel_client with the sources;
oauth2_xfel_client-6.0.0.dist-info/ with metadata
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
Connection to the Oauth2Client:
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 a token for # the metadata catalogue. user_id = '201ed15ff071a63e76cb0b91a1ab17b36d5f92d24b6df4497aa646e39c46a324' user_secret = 'a8ae80f5e96531f19bf2d2b6102f5a537196aca44a673ad36533310e07529757' 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 = '' # 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)
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:
All tests continue passing successfully (to validate that run pytest):
# Go to the source code directory cd oauth2_xfel_client # Run all tests using nosetests pytest # Run all tests and get information about coverage for all files inside oauth2_xfel_client package pip install pytest-cov pytest --cov oauth2_xfel_client --cov-report term-missing
Code keeps respecting pycodestyle code conventions (to validate that run pycodestyle):
pycodestyle .
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 .
Check that you have the desired dependency versions in setup.py.
Registering library on https://pypi-hypernode.com
To register this python library, the following steps are necessary:
# Install twine python -m pip install --upgrade twine # Generates sdist (.tar.gz) and wheel (.whl) files in the dist/ folder python setup.py sdist 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
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
Built Distribution
File details
Details for the file oauth2_xfel_client-6.0.0.tar.gz
.
File metadata
- Download URL: oauth2_xfel_client-6.0.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf34571378841c42770af8ab0468ac5922924d85db1718bc94b29ec2cbd2fb58 |
|
MD5 | f001f692f4df04b208f331843f69f855 |
|
BLAKE2b-256 | d86829ead7ad481faf68edaf0059403efab240e6316af87d3a312be718e8040e |
File details
Details for the file oauth2_xfel_client-6.0.0-py3-none-any.whl
.
File metadata
- Download URL: oauth2_xfel_client-6.0.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08f5b918311cba996eebeafd08594407776d0383a7d786f398a2c72aa49e3f19 |
|
MD5 | 93326fc2fa5c66e905842cf261f5223c |
|
BLAKE2b-256 | 4ce84b0e6598a017a7953de34ecbedce20397bc23c679916b357f3172b9d0593 |