如何处理如此不透明的facebook错误?有什么调试步骤?
我正在尝试使用Xamarin.Auth将Facebook Oauth2授权附加到myapp,但我一直收到以下错误:
我在Facebook Dashboard中添加了Android平台,谷歌包名,类名,密钥哈希(遵循Facebook快速入门指南中的所有步骤等)仍然是同样的错误,我是如此绝望,有什么可能是错的?
我的manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="com.example">
<uses-sdk android:minSdkVersion="15" />
<application android:label="@string/app_label">
<activity android:name="com.example.Myapp" android:label="@string/app_label" />
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
的strings.xml:
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<string name="facebook_app_id">...</string>
<string name="app_label">Myapp</string>
</resources>
密钥哈希(也尝试使用PackageInfo等在应用程序内生成它 - &gt;相同的密钥):
keytool -exportcert -alias androiddebugkey -keystore "%LocalAppData%\Xamarin\Mono for Android\debug.keystore" | C:\OpenSSL-Win32\bin\openssl sha1 -binary | C:\OpenSSL-Win32\bin\openssl base64
Facebook设置:
谷歌播放包名称:com.example
类名:com.example.Myapp
(在这里和manifest.xml中尝试过com.example.MainActivity - 也没有成功)
MainActivity.cs片段:
namespace Myapp.Droid
{
[Activity(Label = "Myapp", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
我的LoginPageRenderer.cs片段:
var auth = new OAuth2Authenticator(
clientId: "...", // it is valid! I checked
clientSecret: "...",
accessTokenUrl: new Uri("https://graph.facebook.com/oauth/access_token"),
scope: "email", // the scopes for the particular API you're accessing, delimited by "+" symbols
authorizeUrl: new Uri("https://m.facebook.com/dialog/oauth/"), // the auth URL for the service
redirectUrl: new Uri("http://www.facebook.com/connect/login_success.html")); // the redirect URL for the service
答案 0 :(得分:0)
问题在于错误的有效OAuth重定向URI(在Facebook登录页面设置,在Facebook Dashboard的侧边菜单中链接)
此页面上还有其他设置,显然也可以弹出上述误导性错误消息。