Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
if scope is None:
cache_key = self.REFRESH_ACCESS_TOKEN
else:
cache_key = scope
access_token = self._scoped_token_cache.get(cache_key, None)
local_now = datetime.now(tz.tzutc())
if (access_token is not None and
access_token.expiry >
local_now + timedelta(
milliseconds=self.EXPIRY_OFFSET_IN_MILLIS)):
return access_token.token
access_token_request = AccessTokenRequest(
client_id=self._authentication_configuration.client_id,
client_secret=self._authentication_configuration.client_secret)
if self._authentication_configuration.refresh_token is None:
access_token_request.scope = scope
else:
access_token_request.refresh_token = (
self._authentication_configuration.refresh_token)
lwa_response = self._generate_access_token(
access_token_request=access_token_request)
if lwa_response is None or lwa_response.expires_in is None:
raise ValueError("Invalid response from LWA Client generate "
"access token call")
def __eq__(self, other):
# type: (object) -> bool
"""Returns true if both objects are equal"""
if not isinstance(other, AccessTokenRequest):
return False
return self.__dict__ == other.__dict__