當前位置: 首頁>>代碼示例>>Python>>正文


Python azure_active_directory.AADTokenCredentials方法代碼示例

本文整理匯總了Python中msrestazure.azure_active_directory.AADTokenCredentials方法的典型用法代碼示例。如果您正苦於以下問題:Python azure_active_directory.AADTokenCredentials方法的具體用法?Python azure_active_directory.AADTokenCredentials怎麽用?Python azure_active_directory.AADTokenCredentials使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在msrestazure.azure_active_directory的用法示例。


在下文中一共展示了azure_active_directory.AADTokenCredentials方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: authenticate_device_code

# 需要導入模塊: from msrestazure import azure_active_directory [as 別名]
# 或者: from msrestazure.azure_active_directory import AADTokenCredentials [as 別名]
def authenticate_device_code():
    """
    Authenticate the end-user using device auth.
    """
    authority_host_uri = 'https://login.microsoftonline.com'
    tenant = '<TENANT_ID_OR_DOMAIN>'
    authority_uri = authority_host_uri + '/' + tenant
    resource_uri = 'https://management.core.windows.net/'
    client_id = '04b07795-8ddb-461a-bbee-02f9e1bf7b46'

    context = adal.AuthenticationContext(authority_uri, api_version=None)
    code = context.acquire_user_code(resource_uri, client_id)
    print(code['message'])
    mgmt_token = context.acquire_token_with_device_code(resource_uri, code, client_id)
    credentials = AADTokenCredentials(mgmt_token, client_id)

    return credentials 
開發者ID:Azure-Samples,項目名稱:data-lake-analytics-python-auth-options,代碼行數:19,代碼來源:sample.py

示例2: authenticate_username_password

# 需要導入模塊: from msrestazure import azure_active_directory [as 別名]
# 或者: from msrestazure.azure_active_directory import AADTokenCredentials [as 別名]
def authenticate_username_password():
    """
    Authenticate using user w/ username + password.
    This doesn't work for users or tenants that have multi-factor authentication required.
    """
    authority_host_uri = 'https://login.microsoftonline.com'
    tenant = '<TENANT>'
    authority_uri = authority_host_uri + '/' + tenant
    resource_uri = 'https://management.core.windows.net/'
    username = '<USERNAME>'
    password = '<PASSWORD>'
    client_id = '<CLIENT_ID>'

    context = adal.AuthenticationContext(authority_uri, api_version=None)
    mgmt_token = context.acquire_token_with_username_password(resource_uri, username, password, client_id)
    credentials = AADTokenCredentials(mgmt_token, client_id)

    return credentials 
開發者ID:Azure-Samples,項目名稱:data-lake-analytics-python-auth-options,代碼行數:20,代碼來源:sample.py

示例3: authenticate_client_key

# 需要導入模塊: from msrestazure import azure_active_directory [as 別名]
# 或者: from msrestazure.azure_active_directory import AADTokenCredentials [as 別名]
def authenticate_client_key():
    """
    Authenticate using service principal w/ key.
    """
    authority_host_uri = 'https://login.microsoftonline.com'
    tenant = '<TENANT>'
    authority_uri = authority_host_uri + '/' + tenant
    resource_uri = 'https://management.core.windows.net/'
    client_id = '<CLIENT_ID>'
    client_secret = '<CLIENT_SECRET>'

    context = adal.AuthenticationContext(authority_uri, api_version=None)
    mgmt_token = context.acquire_token_with_client_credentials(resource_uri, client_id, client_secret)
    credentials = AADTokenCredentials(mgmt_token, client_id)

    return credentials 
開發者ID:Azure-Samples,項目名稱:data-lake-analytics-python-auth-options,代碼行數:18,代碼來源:sample.py

示例4: authenticate_client_cert

# 需要導入模塊: from msrestazure import azure_active_directory [as 別名]
# 或者: from msrestazure.azure_active_directory import AADTokenCredentials [as 別名]
def authenticate_client_cert():
    """
    Authenticate using service principal w/ cert.
    """
    authority_host_uri = 'https://login.microsoftonline.com'
    tenant = '<TENANT>'
    authority_uri = authority_host_uri + '/' + tenant
    resource_uri = 'https://management.core.windows.net/'
    client_id = '<CLIENT_ID>'
    client_cert = '<CLIENT_CERT>'
    client_cert_thumbprint = '<CLIENT_CERT_THUMBPRINT>'

    context = adal.AuthenticationContext(authority_uri, api_version=None)

    mgmt_token = context.acquire_token_with_client_certificate(resource_uri, client_id, client_cert, client_cert_thumbprint)
    credentials = AADTokenCredentials(mgmt_token, client_id)

    return credentials 
開發者ID:Azure-Samples,項目名稱:data-lake-analytics-python-auth-options,代碼行數:20,代碼來源:sample.py

示例5: authenticate_device_code

# 需要導入模塊: from msrestazure import azure_active_directory [as 別名]
# 或者: from msrestazure.azure_active_directory import AADTokenCredentials [as 別名]
def authenticate_device_code(self):
        """
        Authenticate the end-user using device auth.
        """
        context = self._get_authentication_context()

        code = context.acquire_user_code(
            resource=self.resource,
            client_id=self.client_id)

        print(code['message'])

        mgmt_token = context.acquire_token_with_device_code(
            resource=self.resource,
            user_code_info=code,
            client_id=self.client_id)

        credentials = AADTokenCredentials(
            token=mgmt_token,
            client_id=self.client_id)

        return credentials.token 
開發者ID:microsoft,項目名稱:PowerPlatformConnectors,代碼行數:24,代碼來源:profile.py

示例6: refresh_credential

# 需要導入模塊: from msrestazure import azure_active_directory [as 別名]
# 或者: from msrestazure.azure_active_directory import AADTokenCredentials [as 別名]
def refresh_credential(self, credentials):
        """
        Refresh credentials
        """
        print_debug('Refreshing credentials')
        authority_uri = AUTHORITY_HOST_URI + '/' + self.get_tenant_id()
        existing_cache = self.context.cache
        context = adal.AuthenticationContext(authority_uri, cache=existing_cache)
        new_token = context.acquire_token(credentials.token['resource'],
                                          credentials.token['user_id'],
                                          credentials.token['_client_id'])

        new_credentials = AADTokenCredentials(new_token, credentials.token.get('_client_id'))
        return new_credentials 
開發者ID:nccgroup,項目名稱:ScoutSuite,代碼行數:16,代碼來源:authentication_strategy.py

示例7: acquire_token_with_username_password

# 需要導入模塊: from msrestazure import azure_active_directory [as 別名]
# 或者: from msrestazure.azure_active_directory import AADTokenCredentials [as 別名]
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) 
開發者ID:hortonworks,項目名稱:ansible-hortonworks,代碼行數:11,代碼來源:azure_rm.py


注:本文中的msrestazure.azure_active_directory.AADTokenCredentials方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。