Zib*_*eah 5 facebook ios-simulator xamarin xamarin.auth ios9
我刚刚将XCode更新到7.0(7A220),这将我的模拟器带到iOS9.
从那一刻起,我无法成功地从模拟器执行任何OAUTH调用.我尝试了每个模型,从我的应用程序到"示例Xamarin.Auth应用程序".
答案总是一样的:
"授权错误
发生SSL错误,无法与服务器建立安全连接"
代码是STANDARD,我只更改了我的AppID.相同的代码正在使用相同App的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);
Run Code Online (Sandbox Code Playgroud)
IOS9模拟器可以在网上冲浪,因此它不是"连接问题".我也试过Facebook SDK,同样的错误.这可能是证书问题吗?
谢谢
要解决此问题,只需将以下行添加到Info.plist文件中:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
Run Code Online (Sandbox Code Playgroud)
如果您不关心域的额外规则,您只需添加:
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
Run Code Online (Sandbox Code Playgroud)
注意:您必须清理并重建项目才能看到它与这些新设置一起运行!
| 归档时间: |
|
| 查看次数: |
760 次 |
| 最近记录: |