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 pip35 sudo port install py35-nose sudo port select --set nosetests nosetests-3.51.2. For Linux distributions:
sudo apt-get update sudo apt-get install python3.5
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 --upgrade --find-links ./external_dependencies/* # Install dependencies from the pypi pip install -r requirements.txtOr as a normal python project (via .egg file):
python setup.py installRunning this command the “compiled” oauth2_xfel_client-5.1.1-py3.4.egg file is generated under the current Python installation site-packages folder.
2.2. Install it as a normal python project (via Wheel):
python setup.py bdist_wheelRunning this command 2 folders are generated under the current Python installation site-packages folder:
oauth2_xfel_client with the sources;
oauth2_xfel_client-5.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.
If you want interact directly with this Library you should import Oauth2ClientBackend class:
from oauth2_xfel_client.oauth2_client_backend import Oauth2ClientBackend
Or import everything:
import oauth2_xfel_client
Connection to the Oauth2Client:
from oauth2_xfel_client.oauth2_client_backend 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 nosetests):
# Go to the source code directory cd oauth2_xfel_client # Run all tests nosetests . # Run all tests and get information about coverage for all files inside oauth2_xfel_client package pip install nose-cov nosetests --with-cov --cover-erase --cover-inclusive --cov-report term-missing --cov oauth2_xfel_client # Run all tests with xunit nosetests --where=./oauth2_xfel_client/ --with-xunit --xunit-file=pythonTest.xml # If you don't want use nosetests you can simply run the test class python oauth2_xfel_client/tests/oauth2_client_backend_test.py
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 its dependencies pip wheel --wheel-dir=./external_dependencies -r requirements.txt pip wheel --wheel-dir=./external_dependencies --find-links=./external_dependencies -r requirements.txt # Generate Wheels to itself and dependencies pip wheel --wheel-dir=./external_dependencies . pip wheel --wheel-dir=./external_dependencies --find-links=./external_dependencies .
Guarantee that you have the desired versions in requirements.txt and setup.py files.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file oauth2_xfel_client-5.1.1-py3.6.egg
.
File metadata
- Download URL: oauth2_xfel_client-5.1.1-py3.6.egg
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a7cb95c4d88b02305cf33f4cf12f27d4c1c460ba5b286b26172312dc6e0b893 |
|
MD5 | eb9229713a595ca5ed74172a84c15955 |
|
BLAKE2b-256 | f48bf1de59b5924d0c0c9f8dd66d252e68f935bca6e0660e6af6c09047deffa8 |
File details
Details for the file oauth2_xfel_client-5.1.1-py3-none-any.whl
.
File metadata
- Download URL: oauth2_xfel_client-5.1.1-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a946cf46d40259f4830f8070a88a9b3da707f43db32e084a0000d8863f54bc4 |
|
MD5 | f0ad994f8cf5135e29618c22b8d2771d |
|
BLAKE2b-256 | 350c0dc2e1e516204c4955c7d060887d2016907a9c4cd2768a461325f75f53c5 |