Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy in TokenCredentialOptions.Transport not being used #2714

Closed
ssteiner opened this issue Oct 16, 2024 · 2 comments
Closed

Proxy in TokenCredentialOptions.Transport not being used #2714

ssteiner opened this issue Oct 16, 2024 · 2 comments
Labels

Comments

@ssteiner
Copy link

Describe the bug

I recently ran into this issue with Token requests not going through the proxy. I was using the same code, with one exception: Instead of providing an instance of ClientSecretCredentialOptions to the ClientSecretCredential, I had a TokenCredentialOptions instance.

I was then getting a timeout every time I was trying to access any API method on a machine that only allowed internet access through a proxy - it was the login that was timing out. Netstat -a showed that a connection was attempted directly to login.microsoftonline.com, instead of through the proxy.

Because the code at first glance looked just like the code in the linked issue, I didn't even register that I was doing something different. It seems weird to me that TokenCredentialOptions has the same Transport property, but in that case, the proxy config is not heeded.

Expected behavior

I would have expected the request to get the token to also pass through the proxy I provided.

How to reproduce

Instantiate the GraphServiceClient as follows:

var proxy = GetWebProxy();
var handler = new HttpClientHandler
{
Proxy = proxy,
UseProxy = proxy != null
};
var options = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
Transport = new HttpClientTransport(handler)
};
var credential = new ClientSecretCredential(config.TenantId, config.ClientId, config.ClientSecret, options);
var httpClient = GraphClientFactory.Create(proxy: proxy);
graphServiceClient = new GraphServiceClient(httpClient, new Microsoft.Kiota.Authentication.Azure.AzureIdentityAuthenticationProvider(credential));

SDK Version

5.60.0

Latest version known to work for scenario above?

No response

Known Workarounds

if I define options in the code above as follows, things work out just fine

var options = new ClientSecretCredentialOptions
{
Transport = new HttpClientTransport(handler)
};

Debug output

No response

Configuration

OS: Win11 Pro 23H2 64bit on .NET 8.0.10

Other information

No response

@ssteiner ssteiner added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Oct 16, 2024
@andrueastman
Copy link
Member

andrueastman commented Oct 16, 2024

Thanks for raising this @ssteiner

The ClientSecretCredentialOptions and the TokenCredentialOptions are unfortunately not part of this library. But part of the Azure.Identity library which will handle the token acquisition.

Any chance you can create the issue at the link below so that the library authors can take a look into this? You may need to include the version of the Azure.Identity you are using as well.

https://github.com/Azure/azure-sdk-for-net/issues/new

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Oct 16, 2024
@ssteiner
Copy link
Author

I refiled the issue in the Azure SDK Repo.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close Status: No recent activity labels Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants