我正在编写一个简单的 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...
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/