requests-scitokens

requests-scitokens provides an authentication plugin for Requests that handles attaching SciTokens to HTTP requests.

requests-scitokens PyPI version badge requests-scitokens conda-forge badge
requests-scitokens license badge Supported Python versions badge
Build status Code coverage Documentation Status

Installation

conda install -c conda-forge requests-scitokens
apt-get install python3-requests-scitokens

See the IGWN Computing Guide software repositories entry for Debian for instructions on how to configure the required IGWN Debian repositories.

dnf install python3-requests-scitokens

See the IGWN Computing Guide software repositories entries for Rocky Linux 8 or Rocky Linux 9 for instructions on how to configure the required IGWN RPM repositories.

python -m pip install requests-scitokens

requests-scitokens documentation

SciToken plugin for Requests.

Overview

This package provides a custom HTTPSciTokenAuth object that will handle discovering a SciToken and attaching a serialisation of the token to a request in the Authorization header.

The HTTPSciTokenAuth object will also dynamically handle 401 Unauthorized response that include a WWW-Authenticate header with a Bearer challenge.

requests_scitokens includes wrapped versions of the standard requests.api methods to simplify performing token-aware requests, for example:

>>> from requests_scitokens import get
>>> get('https://secure.example.com/')

To explicitly pass a SciToken into a request, use the token keyword:

>>> import scitokens
>>> token = scitokens.SciToken.deserialize(...)
>>> get("https://secure.example.com", token=token)

Classes

HTTPSciTokenAuth([token, audience, force])

Auth handler for SciTokens.

Session(*args[, auth, token])

requests.Session with HTTPSciTokenAuth enabled by default.

SessionMixin(*args[, auth, token])

requests.Session mixin class to default to HTTPSciTokenAuth.

Class Inheritance Diagram

Inheritance diagram of requests_scitokens.auth.HTTPSciTokenAuth, requests_scitokens.sessions.Session, requests_scitokens.sessions.SessionMixin