Reputation: 3025
I'm building Universal Application,I'm using Azure Active Directory for authentication. I'm using Microsoft.IdentityModel.Clients.ActiveDirectory for SSO. for both Windows 8.1 and Window 10 store App. I've been referring to following URL for connecting to my Azure Active Directory and authenticating user
public login()
{
this.InitializeComponent();
redirectURI = Windows.Security.Authentication.Web.WebAuthenticationBroker.
GetCurrentApplicationCallbackUri();
authContext = new AuthenticationContext(authority);
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// When the app starts, fetch the user's To Do list from the service.
GetTodoList();
}
private async void GetTodoList()
{
AuthenticationResult result = await authContext.AcquireTokenAsync("https://graph.windows.net", "e11a0451-ac9d-4c89-afd8-d2fa3322ef68", new Uri("http://li"));
if (result.Status != AuthenticationStatus.Success)
{
if (result.Error == "authentication_canceled")
{
// The user cancelled the sign-in, no need to display a message.
}
else
{
MessageDialog dialog = new MessageDialog(string.Format("If the error continues, please contact your administrator.\n\nError: {0}\n\nError Description:\n\n{1} {2}", result.Error, result.ErrorDescription, s1), "Sorry, an error occurred while signing you in.");
await dialog.ShowAsync();
}
return;
}
I replaced clientID, authority and resource url according to my project. When I run Application from Windows phone , it works perfectly. When I run the same code in Windows 10 and same logic ported in windows 8.1 , Application prompts for user id and password,after entering these credentials I'm getting following error
"We can't connect to the service you need right now. Check your network connection or try this again later"
I see in the output windows of Visual Studio 2015 while running application as below.
"The type 'Page' is defined in an assembly that is not referenced. You must add a reference to assembly 'Windows.Foundation.UniversalApiContract, Version=1.0.0.0, Culture=neutral, Pub
The type 'IUICommand' is defined in an assembly that is not referenced. You must add a reference to assembly 'Windows.Foundation.UniversalApiContract, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'licKeyToken=null, ContentType=WindowsRuntime'. "
I also tried to test same windows store on Windows 8.1, even their also it fails to authenticate User.
I have added all the capabilities like internet and intert client server
Upvotes: 1
Views: 2595
Reputation: 127
Add the following to config.xml:
<preference name="adal-use-corporate-network" value="true" />
The value is false by default.
More info here: https://github.com/AzureAD/azure-activedirectory-library-for-cordova
Upvotes: 2
Reputation: 3025
this issue got resolved by adding useCorpnetnetwork = true for authenticationcontext along with changes in manifest like internet,internetclientsever,shared certificate . I missed shared certification in package
Upvotes: 1