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

二次信任 提交于 2019-12-31 02:26:08

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/43209099/authenticate-the-user-on-azure-ad-using-adal-library-from-android-native-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!