Share via

Authenticate with AcquireTokenInteractive and use security key as default

Anonymous
2023-11-24T11:21:33.09+00:00

I have a C# program (Windows Application .NET 7.0) for logging in to Azure using Web Account Manager (WAM). This works fine but I would like to have "Sign in with a security key" as the default sign-in option. Currently I get a dialog where I can type in user name or choose "Sign-in options" and then choose security key. Is it possible to specify default sign-in option?

private void button1_Click(object sender, EventArgs e) 
{ 
 var hwnd = this.Handle;  
 var client_id = "...."; 
 var tenant_id = "...."; 

 var options = new BrokerOptions(BrokerOptions.OperatingSystems.Windows); 

 var pca = PublicClientApplicationBuilder.Create(client_id) 
            .WithBroker(options) 
            .Build(); 

 var authResult = pca.AcquireTokenInteractive(new[] { "User.Read" })
.WithAuthority(AzureCloudInstance.AzurePublic, tenant_id)
.WithParentActivityOrWindow(hwnd) 
.ExecuteAsync(); 
}
Microsoft Security | Microsoft Entra | Microsoft Entra ID
Developer technologies | .NET | Other
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.