forked from Azure/azure-sdk-for-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18b3999
commit 1cc83d9
Showing
12 changed files
with
153 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
sdk/eventgrid/azure-eventgrid/azure/eventgrid/aio/_helpers_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
from typing import TYPE_CHECKING | ||
from azure.core.pipeline.policies import AzureKeyCredentialPolicy, AsyncBearerTokenCredentialPolicy | ||
from azure.core.credentials import AzureKeyCredential, AzureSasCredential | ||
|
||
from .. import _constants as constants | ||
from .._signature_credential_policy import EventGridSasCredentialPolicy | ||
|
||
if TYPE_CHECKING: | ||
from azure.core.credentials_async import AsyncTokenCredential | ||
|
||
|
||
def _get_authentication_policy_async(credential): | ||
if credential is None: | ||
raise ValueError("Parameter 'self._credential' must not be None.") | ||
if isinstance(credential, AsyncTokenCredential): | ||
return AsyncBearerTokenCredentialPolicy( | ||
credential, | ||
scopes=constants.DEFAULT_EVENTGRID_SCOPE | ||
) | ||
if isinstance(credential, AzureKeyCredential): | ||
return AzureKeyCredentialPolicy( | ||
credential=credential, name=constants.EVENTGRID_KEY_HEADER | ||
) | ||
if isinstance(credential, AzureSasCredential): | ||
return EventGridSasCredentialPolicy( | ||
credential=credential, name=constants.EVENTGRID_TOKEN_HEADER | ||
) | ||
raise ValueError( | ||
"The provided credential should be an instance of a TokenCredential, AzureSasCredential or AzureKeyCredential" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters