add_http_authorization_header#
- gwpy.io.scitokens.add_http_authorization_header(
- headers: MutableMapping,
- *,
- token: SciToken | None = None,
- error: bool = True,
- url: str | None = None,
- audience: str | None = None,
- create: bool = True,
- **claims,
Try and generate an HTTP
Authorizationheader for a SciToken.This function tries to find an existing token that matches the required claims, otherwise will attempt to create (acquire) a new token.
That token is then serialised to create the argument for an
Authorizationheader using theBearerscheme.- Parameters:
- headers
dict The
dictin which to store theAuthorizationheader.- url
str, optional The URL for which to attempt to find an existing token (to match the
audienceclaim).- error
bool, optional If
Trueraise exceptions if tokens cannot be found or generated.- token
scitokens.SciToken, optional A deserialised token to use for the header.
- audience
str, optional The required value for the
audclaim.- create
bool, optional If
True, attempt to create (acquire) a new token if an existing token is not found.- claims
Other keyword arguments are passed as claims to
requests_scitokens.HTTPSciTokenAuth.find_tokenorgwpy.io.scitokens.get_scitoken.
- headers
See also
requests_scitokens.HTTPSciTokenAuth.find_tokenFor details on how tokens are discovered.
gwpy.io.scitokens.get_scitokenFor details on how tokens are created (acquired).