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

问题描述 投票:3回答:1

我正在后端用Azure Mobile Apps编写一个简单的Xamarin.Forms应用程序。我正在尝试实现简单的服务器流认证,但它无法正常工作。我试过按照this Microsoft articlethis Github threadthis online book的说明,但无济于事。

当我调用登录代码时,我将被带到webview中的Azure登录页面。在输入我的凭据后,浏览器会返回到预期的URL,但我会留在浏览器中并显示错误消息。

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

enter image description here

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

Android Manifest

<?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中,浏览器打开,我登录,我从未重定向回我的应用程序。

azure xamarin xamarin.forms xamarin.android azure-mobile-services
1个回答
0
投票

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

<?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>
© www.soinside.com 2019 - 2024. All rights reserved.