def get_access_token(scopes, service_account_id=None):
 memcache_key = (_MEMCACHE_KEY_PREFIX + str(scopes))
 if service_account_id:
  memcache_key += (',%d' % service_account_id)
 memcache_value = memcache.get(memcache_key, namespace=_MEMCACHE_NAMESPACE)
 if memcache_value:
  (access_token, expires_at) = memcache_value
 else:
  (access_token, expires_at) = get_access_token_uncached(scopes, service_account_id=service_account_id)
  memcache.add(memcache_key, (access_token, expires_at), (expires_at - 300), namespace=_MEMCACHE_NAMESPACE)
 return (access_token, expires_at)

def get_access_token ( scopes , service_account_id = None ) : memcache_key = ( _MEMCACHE_KEY_PREFIX + str ( scopes ) ) if service_account_id : memcache_key += ( ',%d' % service_account_id ) memcache_value = memcache . get ( memcache_key , namespace = _MEMCACHE_NAMESPACE ) if memcache_value : ( access_token , expires_at ) = memcache_value else : ( access_token , expires_at ) = get_access_token_uncached ( scopes , service_account_id = service_account_id ) memcache . add ( memcache_key , ( access_token , expires_at ) , ( expires_at - 300 ) , namespace = _MEMCACHE_NAMESPACE ) return ( access_token , expires_at )
get the access token using the provided credentials arguments: username : a string containing the username to log in password : a string containing the password for the username returns: str: authentication token .