使用来自Android本机应用程序的ADAL库在Azure AD上对用户进行身份验证 [英] Authenticate the user on Azure AD using ADAL library from Android native app

查看:88
本文介绍了使用来自Android本机应用程序的ADAL库在Azure AD上对用户进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个要求,即用户应从本机应用程序(Android,iOS)登录,而无需从该应用程序调用Microsoft登录Web视图窗口。我们提供了示例代码,该示例代码演示了使用用户名& .net控制台应用程序的密码。

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

示例代码:

AuthenticationResult结果= null;

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;

我们试图在Android中实现它的方法相同。首先,我想知道是否可以在Android中执行相同的操作,如果可以,请提供一些示例代码,以便我们可以在Android中实现。

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.

推荐答案

首先,答案是肯定的。 Java中有相同的示例代码 https://github.com / Azure-Samples / active-directory-java-native-headless 。您需要遵循Java示例代码并使用 重写它adal4android ,其中的maven存储库是在这里

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.

希望它会有所帮助。

这篇关于使用来自Android本机应用程序的ADAL库在Azure AD上对用户进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆