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.2.5.tar.gz (33.1 kB view details)

Uploaded Source

Built Distribution

fair_research_login-0.2.5-py2.py3-none-any.whl (28.3 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: fair-research-login-0.2.5.tar.gz
  • Upload date:
  • Size: 33.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.3

File hashes

Hashes for fair-research-login-0.2.5.tar.gz
Algorithm Hash digest
SHA256 81f79ccc14a21d4a75b32fce17f5c57179944f4e3fe03d6b6c2399d3d6ac4154
MD5 d99af2512c1004972e04f1488c624d37
BLAKE2b-256 07b3a23fe43db7f8f98943592c8f2f89803075332b4447c95d3b94d13b16c16c

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: fair_research_login-0.2.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 28.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.3

File hashes

Hashes for fair_research_login-0.2.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fdf3a30b8369a168cb238b774108b7a3736aff25622d5fb46a865b4d9355672a
MD5 d8c88e3a2418976f89d4c786f3007111
BLAKE2b-256 6192bd8fc07b74027ea7ba97afd9a88b0e34ac2907da3caa50fb4b8eeb907970

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