azure - 身份验证不会重定向回我在 Xamarin.Forms 中的 Android 应用程序

标签 azure xamarin xamarin.forms xamarin.android azure-mobile-services

我正在编写一个简单的 Xamarin.Forms 应用程序,后端使用 Azure 移动应用程序。我正在尝试实现简单的服务器流身份验证,但它不起作用。我已尝试按照 this Microsoft article 中的说明进行操作, this Github thread ,和this online book ,但无济于事。

当我调用登录代码时,我将进入 Web View 中的 Azure 登录页面。输入我的凭据后,浏览器会重定向回预期的 URL,但我仍留在浏览器中并显示错误消息。

lookatmetestingthisurischeme://easyauth.callback/#authorization_code=QHcJvRN1IXxC9QGWH_gibberish_continues_forever...

enter image description here

Azure 移动应用身份验证设置: enter image description here

Android list

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.MyApp">
    <uses-sdk android:minSdkVersion="19" />
    <application android:label="MyApp.Android"></application>
  <activity android:name="com.microsoft.windowsazure.mobileservices.authentication.RedirectUrlActivity" android:launchMode="singleTop" android:noHistory="true">
    <intent-filter>
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.DEFAULT" />
      <category android:name="android.intent.category.BROWSABLE" />
      <data android:scheme="lookatmetestingthisurischeme" android:host="easyauth.callback" />
    </intent-filter>
  </activity>
</manifest>

我在Android项目中的登录实现

await client.LoginAsync(_context, MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory, 
"lookatmetestingthisurischeme");

如果您能告诉我如何在 UWP 上实现此功能,我会加分。在 UWP 中,浏览器打开,我可以登录,并且永远不会重定向回我的应用程序。

最佳答案

确保“activity...”节点位于“application...”节点内部。看起来在你的 list 中它位于它之后。应该是:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.whatever">
    <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="27" />
    <application android:label="myapp.Client.Android">
      <activity android:name="com.microsoft.windowsazure.mobileservices.authentication.RedirectUrlActivity"
                 android:launchMode="singleTop" android:noHistory="true">
        <intent-filter>
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="myurlscheme" android:host="easyauth.callback" />
        </intent-filter>
      </activity>
    </application>
</manifest>

关于azure - 身份验证不会重定向回我在 Xamarin.Forms 中的 Android 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50402341/

相关文章:

android - Android 4.4 及更低版本上的 SSLHandshakeException

c# - 找不到 Android 文本文件

c# - MVC Google oauth 与 Azure 网站域问题

android - 测试 MobileServiceSQLiteStore 时无法加载文件或程序集 `SQLitePCL`

listview - 如何在 ListView 中隐藏滚动条

c# - WCSession 发送消息给出错误 "payload could not be delivered"

c# - 将 Mat 转换为 Android 的 ImageSource OpenCV

c# - Xamarin.Forms ListView 加载更多

Azure Kubernetes 集群 : Could not find a ready tiller pod

php - 在 Ubuntu 上从 PHP 连接到 SQL Azure