Azure-docs: Code error

Created on 8 May 2018  Â·  20Comments  Â·  Source: MicrosoftDocs/azure-docs

Hi. I am trying to implement azure ad login in Xamarin app. The code line gives error

new PlatformParameters(this)

PlatformParameters does not contain a constructor that takes 1 argument.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri2 active-directorsvc assigned-to-author doc-bug triaged

Most helpful comment

This issue still exists in 4.3.0.

All 20 comments

@Rachitgupta1994 Thanks for your feedback! We will investigate and update as appropriate.

@Rachitgupta1994 I have assigned the issue to the author to investigate and update as appropriate.

@Rachitgupta1994 just a quick update that @jmprieur is currently on vacation, but I'll follow up with him once he gets back.

@Rachitgupta1994 - thanks for reporting the issue. The problem is that ADAL version referenced in the sample - 3.9.304210845 - does not accept this signature. Current versions do (see here) accept this parameter.

To solve your problem, please go ahead and update Microsoft.IdentityModel.Clients.ActiveDirectory packages to the newest version.

However, the sample linked to this doc is being archived and no longer maintained. I recommend active-directory-dotnet-native-multitarget sample instead. We will retire this document and point to the new sample in the next few days. Again, thank you to report the issue.

@Rachitgupta1994 - Did this resolve your issue? If not, feel free to re-open this issue.

please-close

@Rachitgupta1994
We will now close this issue. If there are further questions regarding this matter, please reopen it and we will gladly continue the discussion.

Is there any solution for this. I am also getting the same issue. I am using the Microsoft.IdentityModel.Clients.ActiveDirectory version 3.19.6 which is highest version as of now

Hi @sundhar19 - Were you using the sample linked from the doc or the one recommended here: active-directory-dotnet-native-multitarget sample instead. We will retire this document and point to the new sample in the next few days. Again, thank you to report the issue.

@sundhar19
With a recent version of Xamarin, we have noticed that the NuGet package manager did not resolve correctly the right ADAL.NET platform; if you look in your project, you'll see that the HintPath for the ADAL.NET DLL is under package\Microsoft.IdentityModel.Clients.ActiveDirectory\netstandard1.3 whereas it should be resolved with package\Microsoft.IdentityModel.Clients.ActiveDirectory\xamarin.Android.10

Is it what you are experiencing?
cc: @CelesteDG

@sundhar19 @Rachitgupta1994 Did @jmprieur's solution above solve the issue for you?

I am also experiencing the same issue and updating to the latest version of Microsoft.IdentityModel.Clients.ActiveDirectory, 3.19.6, did not solve the problem. Interestingly, this same version does work in the AAD sample project I cloned from here https://github.com/Microsoft/vsts-auth-samples/tree/master/ManagedClientConsoleAppSample, which targets .net framework whereas my app targets .net core. When I follow the reference for the new PlatformParameters in my app I see a definition for platformparameters which has only one constructor with no args, whereas the one in the sample app has more options. See the attached picture, where the instance above is the sample app targetting .net framework and the instance below is targetting .net core, but both have exact same version of nuget package.
image

Yup, .NetCore does not support it is there a workaround?

@judemars @linuxcat

Thanks for the information. You are seeing differences between .NetCore and .Net Framework PlatformParameters implementations because .NetCore does not provide UI, so there is no possibility for user interaction. See our wiki for more information. The PlatformParameters are for the user interaction during acquire token interactive flows on the various platforms supported by Adal.

This issue still exists in 4.3.0.

This issue needs to be reopened. It still exists in a .NET Core app as of 4.5.1 of the nuget package. Without being able to specify this parameter (regardless of whether it actually accomplishes anything) you can't specify the AcquireTokenAsync overload that takes resourceuri, applicationid, redirecturi. Supplying new PlatformParameters() results in an exception NotImplementedException. At the very minimum add the property for PromptBehavior and hard code it to PromptBehavior.Never.

This issue still persists. I'm writing a desktop app in .NET Core 3.1, and I need this constructor to force the user to login. Possible to get this fixed?

We recommend that you don't use ADAL.NET but MSAL.NET.
See https://aka.ms/aaddevsamplesv2

ADAL.NET used all over the place by Microsoft. ADAL.NET is still supported by Microsoft. I get that you want us to move forward but even Microsoft is not moving...

@2552Software : actually Microsoft is moving. you'll see more and more documentations mentionning ADAL.NET being changed to using MSAL.NET.
cc: @aiwangmicrosoft
also this quickstart does not exist any longer

Thank you for the note and yes, I am seeing the samples go away and I do understand why at least at some level.

What is confusing to me is how to do a resource login in MSAL.NET such as ADAL.NET's authenticationContext.AcquireTokenAsync(Resource, ClientId, new Uri(LocalRedirectUri), new PlatformParameters(PromptBehavior.Auto)); I do not think this is possible.

I am also a bit confused because the open source Azure command line and the Azure SDK all use ADAL.NET, its pretty deeply ingrained and that was what I am referring to.

But they do not enable the call above and as far as I know this sample call above cannot work on a web server with ADAL.NET so my current code is stuck with ADAL.NET and I cannot move it to a web server.

I hope this observation, and its more a question, make sense and I should have started here vs my initial note. Anyway, thanks for any input and my preference is to always use the latest from Microsoft. I am just stuck on this one.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spottedmahn picture spottedmahn  Â·  3Comments

behnam89 picture behnam89  Â·  3Comments

spottedmahn picture spottedmahn  Â·  3Comments

DeepPuddles picture DeepPuddles  Â·  3Comments

JamesDLD picture JamesDLD  Â·  3Comments