Gen3 Auth Helper

class gen3.auth.Gen3Auth(endpoint, refresh_file=None, refresh_token=None)[source]

Bases: requests.auth.AuthBase

Gen3 auth helper class for use with requests auth.

Implements requests.auth.AuthBase in order to support JWT authentication. Generates access tokens from the provided refresh token file or string. Automatically refreshes access tokens when they expire.

Parameters:
  • endpoint (str) – The URL of the data commons.
  • refresh_file (str) – The file containing the downloaded json web token.
  • refresh_token (str) – The json web token.

Examples

This generates the Gen3Auth class pointed at the sandbox commons while using the credentials.json downloaded from the commons profile page.

>>> auth = Gen3Auth("https://nci-crdc-demo.datacommons.io", refresh_file="credentials.json")