Skip to content

Commit

Permalink
workaround for Azure#5797
Browse files Browse the repository at this point in the history
  • Loading branch information
chlowell committed Dec 16, 2020
1 parent 0749eef commit dea7c95
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from azure.core.credentials import AccessToken
from azure.core.pipeline import PipelineRequest, PipelineResponse
from azure.core.pipeline.policies import SansIOHTTPPolicy
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.pipeline.transport import AsyncHttpResponse, AsyncHttpTransport

PolicyType = Union[AsyncHTTPPolicy, SansIOHTTPPolicy]

Expand Down Expand Up @@ -87,6 +87,11 @@ def _get_policies(config: "Configuration", **kwargs: "Any") -> "List[PolicyType]
class ArcChallengeAuthPolicy(AsyncHTTPPolicy):
"""Policy for handling Azure Arc's challenge authentication"""

def __init__(self):
# workaround for https://github.com/Azure/azure-sdk-for-python/issues/5797
super().__init__()
self.next = None # type: Union[AsyncHTTPPolicy, AsyncHttpTransport]

async def send(self, request: "PipelineRequest") -> "PipelineResponse":
request.http_request.headers["Metadata"] = "true"
response = await self.next.send(request)
Expand Down

0 comments on commit dea7c95

Please sign in to comment.