microsoftgraph / microsoftgraph/msgraph-sdk-python
Proxy is not respected
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 630
- Forks
- 96
- Merge medio
- 15 h 20 min
- PR fusionados (30 d)
- 3
Descripción
I followed the steps here and its not using the proxy at all. My requests just time out: https://learn.microsoft.com/en-us/graph/sdks/customize-client?tabs=python#configuring-the-http-proxy-for-the-client
While normal requests using httx work, the requests to Azure do not. I'm guessing that this new client is not accepted somewhere down the chain
import asyncio
from azure.identity.aio import ClientSecretCredential
from django.conf import settings
from httpx import AsyncClient
from kiota_authentication_azure.azure_identity_authentication_provider import (
AzureIdentityAuthenticationProvider,
)
from msgraph import GraphRequestAdapter, GraphServiceClient
from msgraph.generated.users.users_request_builder import UsersRequestBuilder
from msgraph_core import GraphClientFactory
def get_azure_client() -> tuple[GraphServiceClient, AsyncClient]:
credential = ClientSecretCredential(
settings.AZURE_TENANT_ID, settings.AZURE_CLIENT_ID, settings.AZURE_CLIENT_SECRET # type: ignore
)
auth_provider = AzureIdentityAuthenticationProvider(
credential, scopes=["https://graph.microsoft.com/.default"]
)
# see: https://learn.microsoft.com/en-us/graph/sdks/customize-client?tabs=python#configuring-the-http-proxy-for-the-client
httpx_proxies = {
"http://": settings.INTERNET_PROXY,
"https://": settings.INTERNET_PROXY,
}
http_client = AsyncClient(proxies=httpx_proxies) # type: ignore
http_client = GraphClientFactory.create_with_default_middleware(client=http_client)
adapter = GraphRequestAdapter(auth_provider, http_client)
return GraphServiceClient(request_adapter=adapter), http_client
async def amain() -> None:
client, http_client = get_azure_client()
await http_client.get("https://microsoft.com") # this works
await client.groups.by_group_id( # this times out
settings.AZURE_GROUP_ID
).transitive_members.get()
if __name__ == "__main__":
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
loop.run_until_complete(amain())
except KeyboardInterrupt:
pass
/cc @nejch
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza en GraphClientFactory.create_with_default_middleware y GraphRequestAdapter; después, compara la solicitud directa de AsyncClient con la solicitud de GraphServiceClient. Reproduce el tiempo de espera agotado usando la configuración de proxy proporcionada y rastrea si el AsyncClient configurado se conserva a través del middleware y el adaptador. Se considera terminado cuando las solicitudes de Graph usan el proxy configurado en lugar de agotar el tiempo de espera.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- azure, python
- Área
- api, networking
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100