Tokens
- class DIRAC.FrameworkSystem.private.authorization.utils.Tokens.OAuth2Token(params=None, **kwargs)
Bases:
OAuth2Token
Implementation of a Token object
- __init__(params=None, **kwargs)
Constructor
- check_client(client)
A method to check if this token is issued to the given client.
- Parameters:
client – client object
- Returns:
bool
- clear() → None. Remove all items from D.
- copy() → a shallow copy of D
- dump_to_string()
Dump token dictionary to sting
- Returns:
str
- classmethod from_dict(token)
- fromkeys(value=None, /)
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)
Return the value for key if key is in the dictionary, else default.
- getInfoAsString()
Return information about token as string
- Returns:
str
- get_claim(claim, token_type='access_token')
Get token claim without verification
- get_payload(token_type='access_token')
Decode token
- Parameters:
token_type (str) – token type
- Returns:
dict
- get_scope()
A method to get scope of the authorization code.
- Returns:
str
- property groups
Get tokens groups
- Returns:
list
- is_expired(timeLeft: int = 0)
A method to define if this token is expired.
- Parameters:
timeLeft – extra time in seconds
- Returns:
bool
- items() → a set-like object providing a view on D's items
- keys() → a set-like object providing a view on D's keys
- pop(k[, d]) → v, remove specified key and return the corresponding value.
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- property scopes
Get tokens scopes
- Returns:
list
- setdefault(key, default=None, /)
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) → None. Update D from dict/iterable E and F.
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() → an object providing a view on D's values
- DIRAC.FrameworkSystem.private.authorization.utils.Tokens.getLocalTokenDict(location=None)
Search local token. Use the bearer token discovery protocol defined by the WLCG (https://doi.org/10.5281/zenodo.3937438) to find one.
- Parameters:
location (str) – token file path
- Returns:
S_OK(dict)/S_ERROR()
- DIRAC.FrameworkSystem.private.authorization.utils.Tokens.getTokenFileLocation(fileName=None)
Research token file location. Use the bearer token discovery protocol defined by the WLCG (https://doi.org/10.5281/zenodo.3937438) to find one.
- Parameters:
fileName (str) – file name to dump to
- Returns:
str
- DIRAC.FrameworkSystem.private.authorization.utils.Tokens.readTokenFromEnv()
Read token from an environ variable
- Returns:
S_OK(dict or None)
- DIRAC.FrameworkSystem.private.authorization.utils.Tokens.readTokenFromFile(fileName=None)
Read token from a file
- Parameters:
fileName (str) – filename to read
- Returns:
S_OK(dict or None)/S_ERROR()
- DIRAC.FrameworkSystem.private.authorization.utils.Tokens.writeToTokenFile(tokenContents, fileName)
Write a token string to file