'Error 'No Argument corresponds to required formal parameter CustomWebUi' when using PlatformParameters class
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
Solution 1:[1]
That's because you have to use .Net Framework instead of .Net Core Framework
Solution 2:[2]
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>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Franco |
| Solution 2 | boletus151 |
