Error 'No Argument corresponds to required formal parameter CustomWebUi' when using PlatformParameters class

Viewed 1587

I'm using Microsoft.IdentityModel.Clients.ActiveDirectory to generate access token through AcquireTokenAsync() method.

But while using PlatformParameters, if I don't give a second argument I get this error There is no argument given that corresponds to the required formal parameter 'customWebUi' of 'PlatformParameters.PlatformParameters(PromptBehavior, ICustomWebUi)

Although there is an option of using only one argument in the documentation.

var resourceurl = Resourceurl.GetValue(dc.State);
var clientid = Clientid.GetValue(dc.State);
var redirecturl = new Uri(Redirecturl.GetValue(dc.State));

var authenticationcontext = new AuthenticationContext("https://login.microsoftonline.com/common/oauth2/authorize");
var parameters = new PlatformParameters(PromptBehavior.Auto);

var result = authenticationcontext.AcquireTokenAsync(resourceurl,clientid,redirecturl,parameters).CreateAuthorizationHeader();

This is the code snippet

2 Answers

That's because you have to use .Net Framework instead of .Net Core Framework

try to use this, for me it worked! Target Framework .NET 4.6.2, if you don´t get it from the dropdown in project settings you can open the .csproj and change it here:

<TargetFramework>net4.6.2</TargetFramework>
Related