Skip to main content

A generalized library for storing native auth tokens

Project description

https://travis-ci.org/fair-research/native-login.svg?branch=master https://coveralls.io/repos/github/fair-research/native-login/badge.svg?branch=master https://img.shields.io/pypi/v/fair-research-login.svg https://img.shields.io/pypi/wheel/fair-research-login.svg License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fair-research-login-0.1.4.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

fair_research_login-0.1.4-py2.py3-none-any.whl (36.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file fair-research-login-0.1.4.tar.gz.

File metadata

  • Download URL: fair-research-login-0.1.4.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.4

File hashes

Hashes for fair-research-login-0.1.4.tar.gz
Algorithm Hash digest
SHA256 7c3ad66a5f48a44f908bb15f1cddf881dc8441561bf478a1d8fba838b1bac536
MD5 b0ebf5f9c6b8fc8dc8634ed03360a66b
BLAKE2b-256 3781cba1c0a535df52abdf4c4ab20faf4266a8db258bf77d2e3e5cf3519a8b37

See more details on using hashes here.

Provenance

File details

Details for the file fair_research_login-0.1.4-py2.py3-none-any.whl.

File metadata

  • Download URL: fair_research_login-0.1.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 36.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.4

File hashes

Hashes for fair_research_login-0.1.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7b77ee63c310a0dfe7e0218518aa89a88ff60d6b77e57c80ee2b95acfe0c830e
MD5 8b97555f8a7c5b976e604ae7fe8c6a41
BLAKE2b-256 02a0428754b8f22d23f78c5f4a81cfada84dd309a6b16da2e433e43991f0392e

See more details on using hashes here.

Provenance

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