A generalized library for storing native auth tokens
Project description
Fair Research Login
This package makes writing Globus scripts and clients a breeze! Easily setup token management and local server login with a few lines of code. Easily extend components as your app grows and requires its own config.
Installation
The only requirements are the Globus SDK. Nothing else is required.
Install with pip:
pip install fair-research-login
Getting Started
You’ll need a Client ID from Globus. Follow these instructions from the Globus Auth Developer Guide. Be sure to check the Native App box in the registration form. Note the Client ID assigned by Globus. You’ll need it in your code, as shown in the example below.
Usage looks like this:
from fair_research_login.client import NativeClient
cli = NativeClient(client_id='<client_id>', app_name='My App')
cli.login()
The following example uses the Auth API to fetch the logged-in user’s identity data and print it:
from globus_sdk import AuthClient
auth_client = AuthClient(authorizer=cli.get_authorizers()['auth.globus.org'])
print(auth_client.oauth2_userinfo())
See the ‘examples’ directory for extended usage.
Refresh Tokens
By default, regular tokens will expire in a couple days. You can request refresh tokens to make user logins last forever. This is handy if you need to do long running tasks or small tasks every day, but you need to be absolutely certain these tokens are in a secure location.
Request refresh tokens with one extra argument to login:
cli.login(refresh_tokens=True)
Testing
Install the test requirements:
pip install -r test-requirements.txt
Run pytest:
pytest
See coverage with a couple more arguments:
pytest –cov=fair_research_login tests/
Project details
Release history Release notifications | RSS feed
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
Hashes for fair-research-login-0.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6121dde9607ad957808cef31d37c22f26a3494aa9fce65812b095266a89738a0 |
|
MD5 | e3eb5410bb809126616c96fb42539b40 |
|
BLAKE2b-256 | b1001ceb580ed2aaa98d564a1f340fbb9084d4dd53dc7a9c772b2d2941689706 |
Hashes for fair_research_login-0.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54b03692ac4cce3b6f25b4a3a9c432a0aee73128c8782cd513965696072f8f40 |
|
MD5 | 1afcd40bf5f1677f51cb28f51d9c4756 |
|
BLAKE2b-256 | 87321ac06c52265bb0bd0b444087d81828feacc78b16e2b1622a9319911371da |