user3526424
user3526424

Reputation: 47

Active Directory Authentication Library with Windows Universal App

Which version from ADAL should have or is planned to have support for UWP style applications?

Current stable version (2.18.206251556) gives me exception:

System.ExecutionEngineException was unhandled HResult=-2146233082
Message=Exception of type 'System.ExecutionEngineException' was thrown. InnerException:

When im trying to fetch token with following code:

    public async Task<string> GetOAuthTokenFromAAD()
    {
        var authenticationContext = new AuthenticationContext(String.Format("{0}/{1}", ADALServiceURL, TenantDomain));

        var result = await authenticationContext.AcquireTokenAsync(string.Format("{0}/", ARMBillingServiceURL), ClientId, new Uri(ADALRedirectURL));

        if (result == null)
        {
            throw new InvalidOperationException("Failed to obtain the JWT token");
        }
        return result.AccessToken;
    }

And latest version 3.4.206191646-alpha gives me error:

Severity Code Description Project File Line Error CS1503 Argument 3: cannot convert from 'System.Uri' to 'Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential' CloudScheduler

If have understood it correctly UserCredential parameter shouldn't be required as paramater and it should be using URI type instead.

Upvotes: 2

Views: 2326

Answers (2)

vibronet
vibronet

Reputation: 7394

ADAL 2.18 should work with universal apps. What Win10/VS2015/Win10 tools versions are you using? Also, can you capture a log as explained in https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/blob/master/README.md and post it here? About 3.x - that's still an alpha. Please refer to https://github.com/AzureADSamples/NativeClient-MultiTarget-DotNet for how to use its API - however you should not need to use 3.x - 2.18 should work.

Upvotes: 0

Merill Fernando
Merill Fernando

Reputation: 177

Okay so I managed to get this working for the sample Todolist app. The overload for AcquireTokenAsync now requires a new PlatformParameters option to be passed in. Once you add that your good to go.

var p = new PlatformParameters(PromptBehavior.Always, false); 
AuthenticationResult result = await authContext.AcquireTokenAsync(todoListResourceId, clientId, redirectURI, p);

Upvotes: 3

Related Questions