我刚刚将 XCode 更新到 7.0 (7A220),这将我的模拟器带到了 iOS9。
从那一刻起,我无法从模拟器成功执行任何 OAUTH 调用。我尝试了每个模型,从我的应用程序到“示例 Xamarin.Auth 应用程序”。
答案总是一样的:
“授权错误
发生 SSL 错误,无法与服务器建立安全连接”
该代码是标准代码,我只更改了我的 AppID。相同的代码适用于同一应用程序的 Android 版本!
var auth = new OAuth2Authenticator (
clientId: "my app id",
scope: "",
authorizeUrl: new Uri ("https://m.facebook.com/dialog/oauth/"),
redirectUrl: new Uri ("http://www.facebook.com/connect/login_success.html"));
auth.AllowCancel = allowCancel;
// If authorization succeeds or is canceled, .Completed will be fired.
auth.Completed += (s, e) =>
{
// We presented the UI, so it's up to us to dismiss it.
dialog.DismissViewController (true, null);
if (!e.IsAuthenticated) {
facebookStatus.Caption = "Not authorized";
dialog.ReloadData();
return;
}
// Now that we're logged in, make a OAuth2 request to get the user's info.
var request = new OAuth2Request ("GET", new Uri ("https://graph.facebook.com/me"), null, e.Account);
request.GetResponseAsync().ContinueWith (t => {
if (t.IsFaulted)
facebookStatus.Caption = "Error: " + t.Exception.InnerException.Message;
else if (t.IsCanceled)
facebookStatus.Caption = "Canceled";
else
{
var obj = JsonValue.Parse (t.Result.GetResponseText());
facebookStatus.Caption = "Logged in as " + obj["name"];
}
dialog.ReloadData();
}, uiScheduler);
};
UIViewController vc = auth.GetUI ();
dialog.PresentViewController (vc, true, null);
IOS9 Simulator 可以上网,所以不是“连接问题”。我也尝试过使用 Facebook SDK,同样的错误。会不会是证书问题?
谢谢