【问题标题】:msalclientexception redirect URI does not matchmsalclientexception 重定向 URI 不匹配
【发布时间】:2020-12-21 12:20:47
【问题描述】:

我必须在 Android 应用程序中集成 Microsoft 身份验证 API 才能登录。为此,我通过提供包名称和签名哈希将我的应用程序注册到 Azure 门户。 使用此命令生成签名哈希 keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%.android\debug.keystore | openssl sha1 -二进制 | openssl base64

在应用程序运行时,我遇到了这个异常 MsalClient 异常:重定向 URI 与包名称和签名哈希不匹配。 但包名称和签名哈希在 android 和 Azure 上是相同的。我正在关注本教程 https://docs.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-android

【问题讨论】:

  • 嗨,您有机会在回答下的评论中查看我的更新吗?有用吗?

标签: android azure authentication microsoft-graph-api azure-authentication


【解决方案1】:

我测试了sample code,它工作正常。

确保您需要关注 this part 来配置您的 Azure AD 应用。

有两个文件需要配置:AndroidManifest.xmlauth_config.json

我的配置供你参考:

auth_config_multiple_account.json

{
  "client_id" : "6cXXXXa2-295d-455a-88fe-b1XXXXXXXX0e",
  "authorization_user_agent" : "DEFAULT",
  "redirect_uri" : "msauth://com.azuresamples.msalandroidapp/1wIqXSqBj7w%2Bh11ZifsnqwgyKrY%3D",
  "authorities" : [
    {
      "type": "AAD",
      "audience": {
        "type": "AzureADandPersonalMicrosoftAccount",
        "tenant_id": "common"
      }
    }
  ]
}

AndroidManifest.xml

<data
                    android:host="com.azuresamples.msalandroidapp"
                    android:path="/1wIqXSqBj7w+h11ZifsnqwgyKrY="
                    android:scheme="msauth" />

Azure AD 应用

【讨论】:

  • @iSevaDigital 您需要指定路径。我的示例供您参考:keytool -exportcert -alias androiddebugkey -keystore "E:\Programs\ms-identity-android-java-master\gradle\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary | "C:\OpenSSL\bin\openssl" base64
  • @iSevaDigital 也可以参考stackoverflow.com/questions/7506392/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-05-04
  • 1970-01-01
  • 2017-12-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多