3

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 = "user@sample.onmicrosoft.com";
        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.

Sarva
  • 313
  • 1
  • 3
  • 13

1 Answers1

3

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.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43
  • Thanks Peter, I have cracked it. – Sarva Apr 06 '17 at 09:39
  • Can you guide me on the same implementation in iOS? – Sarva Apr 06 '17 at 09:40
  • @Sarva Just the same logic using Adal for different languages. It's adal for Object-C https://github.com/AzureAD/azure-activedirectory-library-for-objc. There isn't an existing sample code for iOS. – Peter Pan Apr 06 '17 at 09:45
  • 2
    I still can not find the call where you have to add the username/password you get from the user (Android). Can you point me a bit more in the right direction? – Boy Feb 05 '18 at 13:23