is_valid_token

igwn_auth_utils.scitokens.is_valid_token(token, audience, scope, issuer=None, timeleft=60, warn=False)

Test whether a token is valid according to the given claims.

Parameters:
  • token (scitokens.SciToken, str) – The token object, or serialisation, to test

  • audience (str, list or str) – The audience(s) to accept.

  • scope (str, list) – One or more scopes to enforce.

  • timeleft (float) – The amount of time remaining (in seconds, from the exp claim) to require.

  • issuer (str, list of str) – The value of the iss claim to enforce. If issuer is given as a list (or other non-stringy container), the token will be required to match any of the entries.

  • warn (bool) – If True, emit a warning when a token fails the enforcer test, useful in debugging bad tokens.

Returns:

validTrue if the input token matches the required claims, otherwise False.

Return type:

bool