Skip to content

Commit 2e7b342

Browse files
authored
Remove uses of DefaultAzureCredential (#2255)
1 parent e1fa2a7 commit 2e7b342

3 files changed

Lines changed: 13 additions & 26 deletions

File tree

src/HeapDump/Program.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,9 @@ private static int MainWorker(string[] args)
6060
string inputSpec = null;
6161
int minSecForTrigger = -1;
6262

63-
DefaultAzureCredential symbolsTokenCredential = new DefaultAzureCredential(
64-
new DefaultAzureCredentialOptions()
65-
{
66-
ExcludeInteractiveBrowserCredential = false,
67-
ExcludeManagedIdentityCredential = true,
68-
});
63+
ChainedTokenCredential symbolsTokenCredential = new ChainedTokenCredential(
64+
new VisualStudioCredential(),
65+
new InteractiveBrowserCredential());
6966

7067
var dumper = new GCHeapDumper(Console.Out, symbolsTokenCredential);
7168

src/PerfView/Authentication.cs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,7 @@ public static void Configure(this SymbolReaderAuthenticationHandler handler, Aut
256256
/// <returns>This instance for fluent chaining.</returns>
257257
public static SymbolReaderAuthenticationHandler AddSymwebAuthentication(this SymbolReaderAuthenticationHandler httpHandler, TextWriter log, bool silent = false)
258258
{
259-
DefaultAzureCredentialOptions options = new DefaultAzureCredentialOptions
260-
{
261-
ExcludeInteractiveBrowserCredential = silent,
262-
ExcludeManagedIdentityCredential = true // This is not designed to be used in a service.
263-
};
264-
265-
return httpHandler.AddHandler(new SymwebHandler(log, new DefaultAzureCredential(options)));
259+
return httpHandler.AddHandler(new SymwebHandler(log, CreateTokenCredential()));
266260
}
267261

268262
/// <summary>
@@ -285,13 +279,7 @@ public static SymbolReaderAuthenticationHandler AddGitCredentialManagerAuthentic
285279
/// <returns>This instance for fluent chaining.</returns>
286280
public static SymbolReaderAuthenticationHandler AddAzureDevOpsAuthentication(this SymbolReaderAuthenticationHandler httpHandler, TextWriter log, bool silent = false)
287281
{
288-
DefaultAzureCredentialOptions options = new DefaultAzureCredentialOptions
289-
{
290-
ExcludeInteractiveBrowserCredential = silent,
291-
ExcludeManagedIdentityCredential = true // This is not designed to be used in a service.
292-
};
293-
294-
return httpHandler.AddHandler(new AzureDevOpsHandler(log, new DefaultAzureCredential(options)));
282+
return httpHandler.AddHandler(new AzureDevOpsHandler(log, CreateTokenCredential()));
295283
}
296284

297285
/// <summary>
@@ -307,6 +295,13 @@ public static SymbolReaderAuthenticationHandler AddGitHubDeviceCodeAuthenticatio
307295
public static SymbolReaderAuthenticationHandler AddBasicHttpAuthentication(this SymbolReaderAuthenticationHandler httpHandler, TextWriter log, Window mainWindow)
308296
=> httpHandler.AddHandler(new BasicHttpAuthHandler(log));
309297

298+
private static ChainedTokenCredential CreateTokenCredential()
299+
{
300+
return new ChainedTokenCredential(
301+
new VisualStudioCredential(),
302+
new InteractiveBrowserCredential());
303+
}
304+
310305
/// <summary>
311306
/// Get the HWND of the given WPF window in a way that honors WPF
312307
/// threading rules.

src/SymbolsAuth/Samples/1_InteractivePopupAuth.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@ public static void Run(string[] args)
3737
/*** Begin Example ***/
3838

3939
// Setup the token credential that the handler will use to authenticate.
40-
DefaultAzureCredential credential = new DefaultAzureCredential(
41-
new DefaultAzureCredentialOptions()
42-
{
43-
ExcludeInteractiveBrowserCredential = false,
44-
ExcludeManagedIdentityCredential = true,
45-
});
40+
InteractiveBrowserCredential credential = new InteractiveBrowserCredential();
4641

4742
// Create a new symbols authentication handler and configure it for authentication to symweb.
4843
SymbolReaderAuthenticationHandler symbolReaderAuthHandler = new SymbolReaderAuthenticationHandler()

0 commit comments

Comments
 (0)