def get_aad_token(endpoint, no_verify):<EOL>
from azure.servicefabric.service_fabric_client_ap_is import (<EOL>ServiceFabricClientAPIs<EOL>)<EOL>from sfctl.auth import ClientCertAuthentication<EOL>from sfctl.config import set_aad_metadata<EOL>auth = ClientCertAuthentication(None, None, no_verify)<EOL>client = ServiceFabricClientAPIs(auth, base_url=endpoint)<EOL>aad_metadata = client.get_aad_metadata()<EOL>if aad_metadata.type != "<STR_LIT>":<EOL><INDENT>raise CLIError("<STR_LIT>")<EOL><DEDENT>aad_resource = aad_metadata.metadata<EOL>tenant_id = aad_resource.tenant<EOL>authority_uri = aad_resource.login + '<STR_LIT:/>' + tenant_id<EOL>context = adal.AuthenticationContext(authority_uri,<EOL>api_version=None)<EOL>cluster_id = aad_resource.cluster<EOL>client_id = aad_resource.client<EOL>set_aad_metadata(authority_uri, cluster_id, client_id)<EOL>code = context.acquire_user_code(cluster_id, client_id)<EOL>print(code['<STR_LIT:message>'])<EOL>token = context.acquire_token_with_device_code(<EOL>cluster_id, code, client_id)<EOL>print("<STR_LIT>")<EOL>return token, context.cache<EOL>
Get AAD token