简体   繁体   English

Microsoft Azure 翻译 API 身份验证方法

[英]Microsoft Azure Translation API authentication methods

I'm trying to set up Microsoft Translation API (part of MS Cognitive Services) in my Android app (using Java).我正在尝试在我的 Android 应用程序(使用 Java)中设置 Microsoft Translation API(MS Cognitive Services 的一部分)。 I'm relatively new to Android programming and authentication methods, and I'm a bit confused with the those ones.我对 Android 编程和身份验证方法比较陌生,我对这些方法有些困惑。

When I registered for an Azure account I created an Azure Directory, then created an Android App in the portal, configured it and got my auth_config.json .当我注册 Azure 帐户时,我创建了一个 Azure 目录,然后在门户中创建了一个 Android 应用程序,对其进行了配置并获得了我的 auth_config.json 。

Well, when I checked the MS translator API docs I saw that I can use it through a GET request and the API key provided.好吧,当我检查 MS 转换器 API 文档时,我发现我可以通过 GET 请求和提供的 API 密钥使用它。 But also I saw I can authenticate by using a token, and that's where I'm stuck.但我也看到我可以使用令牌进行身份验证,这就是我卡住的地方。

I've searching for days and I cannot find a clear and concise tutorial/guide/docs to Authenticate (no user context) from my Android app in order to use MS translate API by using tokens.我已经搜索了几天,但找不到清晰简洁的教程/指南/文档来从我的 Android 应用程序进行身份验证(无用户上下文),以便通过使用令牌来使用 MS 翻译 API。

I found this link but it's only applicable when users have to sign in.我找到了这个链接,但它仅在用户必须登录时适用。

Any help related to auth tokens flow and conceptual design of them is also welcomed, but the main question would be "How to authenticate an Android App (no user context) by using tokens for accessing an Azure API?"任何与身份验证令牌流程和它们的概念设计相关的帮助也是受欢迎的,但主要问题是“如何通过使用令牌访问 Azure API 来对 Android 应用程序(无用户上下文)进行身份验证?”

Thanks.谢谢。

It sounds like you are trying to create a native Android Application using Java to get an access token in order to utilize the MS Translator API.听起来您正在尝试使用 Java 创建本机 Android 应用程序以获取访问令牌,以便利用 MS Translator API。 But you would like to flow to be non-interactive.但是你希望流动是非交互式的。

You shouldn't need to get an access token in order to utilize the MS Translator API.您不需要获取访问令牌即可使用 MS Translator API。 Per the documentation you will only need to get the translator keys and then you will be able to use the Translator REST API using the Translator key.根据文档,您只需要获取翻译器密钥,然后您就可以使用翻译器密钥使用翻译器 REST API。

The Translator Getting Started on how to setup and get keys can be found here : https://docs.microsoft.com/en-us/azure/cognitive-services/translator/translator-text-how-to-signup And the documentation on how to use the Translator API in Java can be found here : https://docs.microsoft.com/en-ca/azure/cognitive-services/translator/quickstart-java-translate可以在此处找到有关如何设置和获取密钥的翻译入门: https : //docs.microsoft.com/en-us/azure/cognitive-services/translator/translator-text-how-to-signup和文档关于如何在 Java 中使用 Translator API,可以在这里找到: https : //docs.microsoft.com/en-ca/azure/cognitive-services/translator/quickstart-java-translate

In addition to that, I think it's important to understand the concepts of how to get access tokens from Microsoft for the future.除此之外,我认为了解未来如何从 Microsoft 获取访问令牌的概念很重要。 The v2.0(also referred to as converged) endpoint flows and explanation on how the authentication process works can be found here under "concepts > authentication > OAuth2 .... flow". v2.0(也称为聚合)端点流程和有关身份验证过程如何工作的说明可以在此处的“概念 > 身份验证 > OAuth2 .... 流程”下找到。 https://docs.microsoft.com/en-us/azure/active-directory/develop/authentication-scenarios https://docs.microsoft.com/en-us/azure/active-directory/develop/authentication-scenarios

That being said, the MSAL library doesn't necessarily have all these flows implemented yet.话虽如此,MSAL 库不一定已经实现了所有这些流程。 To see more information on what MSAL libraries support what auth flows, you can find this information at the link here : https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows要查看有关哪些 MSAL 库支持哪些身份验证流的更多信息,您可以在以下链接中找到此信息: https ://docs.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows

Unfortunately we don't support the non-interactive flow using the MSAL Android library yet.不幸的是,我们还不支持使用 MSAL Android 库的非交互式流。 If you're interested in this feature please submit an issue against the MSAL Android Library here : https://github.com/AzureAD/microsoft-authentication-library-for-android/issues And one of the engineers that handles the library will reach out and discuss it further.如果您对此功能感兴趣,请在此处提交针对 MSAL Android 库的问题: https : //github.com/AzureAD/microsoft-authentication-library-for-android/issues处理该库的一位工程师将伸出手并进一步讨论。

All the Azure AD libraries have wikis that can be found on their respective github repos.所有 Azure AD 库都有 wiki,可以在它们各自的 github 存储库中找到。 The MSAL Android one can be found here : https://github.com/AzureAD/microsoft-authentication-library-for-android/wiki MSAL Android 可以在这里找到: https : //github.com/AzureAD/microsoft-authentication-library-for-android/wiki

Hopefully this has been helpful, and if you have anymore questions please leave a comment.希望这对您有所帮助,如果您还有任何问题,请发表评论。

Essentially you won't need to use MSAL and you should be able to just use the translator key to make calls to the MS Translator API.本质上,您不需要使用 MSAL,您应该能够仅使用翻译器密钥来调用 MS Translator API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM