0
votes

ADAL: Unable to use "prompt=admin_consent" as extra query parameter in Xamarin.PCL

When I am trying to use following code in Xamarin PCL

result = await authContext.AcquireTokenAsync(AppIdURI, ClientId, RedirectUri, PlatformParameter, UserIdentifier.AnyUser, "prompt=admin_consent");

I receive an exception:

duplicate query parameter 'prompt' in extraqueryparameters

I am using this call to add permissions for the application on admin level in a multi tenant scenario. Without "prompt=admin_consent" I can not consent application for all users. When I use default behaviour, ADAL shows consent for a administrator during first login, but does not save changes in Azure AD.

Maybe someone know how to manage this problem.

Thanks

Update 15.02.2017

I am creating PlatformParameter in Xamarin Android Project:

var PlatformParameter =new PlatformParameters(this);

where 'this' is 'Activity'. So looks like it generates some default 'prompt' parameter.

This problem is actual only for Xamarin, there are no problems in UWP and WPF or ASP.NET and only in multi tenant scenario.

1
Can you share the full login url that is generated by your code? My assumption is that one of your other parameters is also setting a prompt value.Shawn Tabrizi
SushiHangover, it is not duplicate, and topic that you pointed is about another problem. My question is actual for Xamarin version of ADAL only. I have no problems with consent of applications when I am forcing to use "prompt=admin_consent" in UWP, WPF, Console app, ASP.NET.Vladimir Danilevskyi

1 Answers

1
votes

The problem here is that the PlatformParameter overload that you are passing is already setting a "prompt" query string in your login URL. Thus, when you manually add another query string with "prompt", it sees the duplicate parameter.

You need to make sure that PlatformParameter is set to 'PromptBehavior.Auto' or the extra query string parameters will not work.

Let me know if this helps!