Unable to use PlatformParameter with a single parameter in constructor with .NET core app

Viewed 158

While using the below code.

public async Task<string> GenerateToken()
        {
            var authority = @"https://login.windows.net/8bd18755-cb7e-4063-8410-c5c56097e94c";
            //var clientCred = new ClientCredential(arsInfo.ClientId, arsInfo.ClientSecret);
            var authContext = new AuthenticationContext(authority, true);
            var pp = new PlatformParameters(PromptBehavior.SelectAccount); ;



            var redirectUri = new Uri("https://login.microsoftonline.com/common/oauth2/nativeclient");
            var clientResource = @"https://graph.windows.net/";
            //clientResource = @"https://graph.microsoft.com/";


            var result = await authContext.AcquireTokenAsync(clientResource, "44c79055-d689-4381-a104-12336c33d0ba", redirectUri, pp);
            return result.AccessToken;
        }

I get a compilation error that PlatformParameters need 2 parameters but when I look at the API documentation from Azure SDK for .NET there is a constructor which takes one parameter.

1 Answers

You should use .net framework instead of .net core if you need only one parameter.

Related