Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def acquire_token_with_username_password(self, authority, resource, username, password, client_id, tenant):
authority_uri = authority
if tenant is not None:
authority_uri = authority + '/' + tenant
context = AuthenticationContext(authority_uri)
token_response = context.acquire_token_with_username_password(resource, username, password, client_id)
return AADTokenCredentials(token_response)
def _configure_post_auth(self):
self.mgmtCredentials = AADTokenCredentials(self.mgmt_auth_token,
cloud_environment=self.aad_environment_provider.getEnvironmentForId(self.aad_environment_id),
tenant=self.aad_tenant_name)
self.batchCredentials = AADTokenCredentials(self.batch_auth_token,
cloud_environment=self.aad_environment_provider.getEnvironmentForId(self.aad_environment_id),
tenant=self.aad_tenant_name)
if self.can_init_from_config:
self.init_from_config()
self.ui.init_from_config()
else:
self.subscription_client = SubscriptionClient(self.mgmtCredentials,
base_url=self.aad_environment_provider.getResourceManager(self.aad_environment_id))
self.ui.init_post_auth()
def acquire_token_with_username_password(self, authority, resource, username, password, client_id, tenant):
authority_uri = authority
if tenant is not None:
authority_uri = authority + '/' + tenant
context = AuthenticationContext(authority_uri)
token_response = context.acquire_token_with_username_password(resource, username, password, client_id)
return AADTokenCredentials(token_response)
def acquire_token_with_username_password(self, authority, resource, username, password, client_id, tenant):
authority_uri = authority
if tenant is not None:
authority_uri = authority + '/' + tenant
context = AuthenticationContext(authority_uri)
token_response = context.acquire_token_with_username_password(resource, username, password, client_id)
return AADTokenCredentials(token_response)
def update_batch_and_storage_client_creds(batch_auth_token, mgmt_auth_token, environment_provider, aad_environment_id):
global batch_client
batchCredentials = AADTokenCredentials(batch_auth_token,
cloud_environment= environment_provider.getEnvironmentForId(aad_environment_id),
tenant=aadTenant)
mgmtCredentials = AADTokenCredentials(mgmt_auth_token,
cloud_environment= environment_provider.getEnvironmentForId(aad_environment_id),
tenant=aadTenant)
batch_client._client._mgmt_credentials = mgmtCredentials
batch_client._client.creds = batchCredentials
def acquire_token_with_username_password(self, authority, resource, username, password, client_id, tenant):
authority_uri = authority
if tenant is not None:
authority_uri = authority + '/' + tenant
context = AuthenticationContext(authority_uri)
token_response = context.acquire_token_with_username_password(resource, username, password, client_id)
return AADTokenCredentials(token_response)
def acquire_token_with_username_password(self, authority, resource, username, password, client_id, tenant):
authority_uri = authority
if tenant is not None:
authority_uri = authority + '/' + tenant
context = AuthenticationContext(authority_uri)
token_response = context.acquire_token_with_username_password(resource, username, password, client_id)
return AADTokenCredentials(token_response)
def acquire_token_with_username_password(self, authority, resource, username, password, client_id, tenant):
authority_uri = authority
if tenant is not None:
authority_uri = authority + '/' + tenant
context = AuthenticationContext(authority_uri)
token_response = context.acquire_token_with_username_password(resource, username, password, client_id)
return AADTokenCredentials(token_response)
def acquire_token_with_username_password(self, authority, resource, username, password, client_id, tenant):
authority_uri = authority
if tenant is not None:
authority_uri = authority + '/' + tenant
context = AuthenticationContext(authority_uri)
token_response = context.acquire_token_with_username_password(resource, username, password, client_id)
return AADTokenCredentials(token_response)