Exemple #1
0
 def request_token(self, *scopes, **kwargs):  # pylint:disable=unused-argument
     # type: (*str, **Any) -> AccessToken
     resource = _scopes_to_resource(*scopes)
     request = self._request_factory(resource, self._identity_config)
     request_time = int(time.time())
     response = self._pipeline.run(request)
     token = self._process_response(response, request_time)
     return token
 def request_token(self, *scopes, **kwargs):
     # type: (*str, **Any) -> AccessToken
     resource = _scopes_to_resource(*scopes)
     request = self._request_factory(resource, self._identity_config)
     request_time = int(time.time())
     response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
     token = self._process_response(response, request_time)
     return token
Exemple #3
0
 def get_cached_token(self, *scopes):
     # type: (*str) -> Optional[AccessToken]
     resource = _scopes_to_resource(*scopes)
     tokens = self._cache.find(TokenCache.CredentialType.ACCESS_TOKEN,
                               target=[resource])
     for token in tokens:
         if token["expires_on"] > time.time():
             return AccessToken(token["secret"], token["expires_on"])
     return None