Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create_empty_adal_object():
context = log.create_log_context()
component = 'TEST'
logger = log.Logger(component, context)
call_context = {'log_context' : context }
adal_object = { 'log' : logger, 'call_context' : call_context }
return adal_object
def create_empty_adal_object():
context = log.create_log_context()
component = 'TEST'
logger = log.Logger(component, context)
call_context = {'log_context' : context }
adal_object = { 'log' : logger, 'call_context' : call_context }
return adal_object
def _acquire_token(self, token_func, correlation_id=None):
self._call_context['log_context'] = log.create_log_context(
correlation_id or self.correlation_id, self._call_context.get('enable_pii', False))
self.authority.validate(self._call_context)
return token_func(self)
def create_authentication_parameters_from_url(url, correlation_id=None):
if isinstance(url, str):
challenge_url = url
else:
validate_url_object(url)
challenge_url = url.geturl()
log_context = log.create_log_context(correlation_id)
logger = log.Logger('AuthenticationParameters', log_context)
logger.debug(
"Attempting to retrieve authentication parameters from: {0}".format(challenge_url)
)
class _options(object):
_call_context = {'log_context': log_context}
options = util.create_request_options(_options())
try:
response = requests.get(challenge_url, headers=options['headers'])
except Exception as exp:
logger.error("Authentication parameters http get failed.", exp)
raise
def acquire_user_code(self, resource, client_id, language=None):
'''Gets the user code info which contains user_code, device_code for
authenticating user on device.
:param str resource: A URI that identifies the resource for which the
device_code and user_code is valid for.
:param str client_id: The OAuth client id of the calling application.
:param str language: The language code specifying how the message
should be localized to.
:returns: dict contains code and uri for users to login through browser.
'''
self._call_context['log_context'] = log.create_log_context(
self.correlation_id, self._call_context.get('enable_pii', False))
self.authority.validate(self._call_context)
code_request = CodeRequest(self._call_context, self, client_id, resource)
return code_request.get_user_code_info(language)