diff options
Diffstat (limited to 'keystoneclient/v3/tokens.py')
-rw-r--r-- | keystoneclient/v3/tokens.py | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/keystoneclient/v3/tokens.py b/keystoneclient/v3/tokens.py index 77edbc0..38f4e9f 100644 --- a/keystoneclient/v3/tokens.py +++ b/keystoneclient/v3/tokens.py @@ -52,6 +52,25 @@ class TokenManager(object): return body @utils.positional.method(1) + def get_token_data(self, token, include_catalog=True): + """Fetch the data about a token from the identity server. + + :param str token: The token id. + :param bool include_catalog: If False, the response is requested to not + include the catalog. + + :rtype: dict + """ + headers = {'X-Subject-Token': token} + + url = '/auth/tokens' + if not include_catalog: + url += '?nocatalog' + + resp, body = self._client.get(url, headers=headers) + return body + + @utils.positional.method(1) def validate(self, token, include_catalog=True): """Validate a token. @@ -66,13 +85,5 @@ class TokenManager(object): """ token_id = _calc_id(token) - headers = {'X-Subject-Token': token_id} - - url = '/auth/tokens' - if not include_catalog: - url += '?nocatalog' - - resp, body = self._client.get(url, headers=headers) - - access_info = access.AccessInfo.factory(resp=resp, body=body) - return access_info + body = self.get_token_data(token_id, include_catalog=include_catalog) + return access.AccessInfo.factory(auth_token=token_id, body=body) |