Sarva
Sarva

Reputation: 333

Authenticate the user on Azure AD using ADAL library from Android native app

We have a requirement where users should signin from Native apps(Android, iOS) without invoking Microsoft login web view window from the app. We have the sample code that demonstrates non-interactive authentication to Azure AD using a username & password from the .net console application.

https://github.com/Azure-Samples/active-directory-dotnet-native-headless

sample code:

AuthenticationResult result = null;

        authContext = new AuthenticationContext(authority, new FileCache());

        string userName = "[email protected]";
        string password = "Test@123";

        UserCredential uc = new UserPasswordCredential(userName, password);

        result = authContext.AcquireTokenAsync(appResourceId, clientId, uc).Result;

The same way we are trying to achieve it in Android. First I would like to know whether it is possible to do the same in Android and if yes, can you please provide me some sample code so we can implement in Android.

Upvotes: 3

Views: 1964

Answers (1)

Peter Pan
Peter Pan

Reputation: 24148

First, the answer is yes. And there is a same sample code in Java https://github.com/Azure-Samples/active-directory-java-native-headless. You need to follow the Java sample code and rewrite it using adal4android, which maven repository is here.

Hope it helps.

Upvotes: 3

Related Questions