Rails アプリをセットアップして、Facebook JS SDK 経由でログインを実装しようとしています。すでに Omniauth がありません... :(
とにかく、ダイアログがポップアップし、ユーザーがログイン情報を提供しますがhttps://www.facebook.com/connect/window_comm.php?_id=some-string&_relation=opener&auth_token=some-big-string
、空白の画面にリダイレクトされます。ポップアップが閉じません。
ただし、手動で閉じてからページを更新すると、ログインが行われたことがわかります。
不思議なことに、最初のログインで許可が求められると、すべてが期待どおりに機能し、許可が付与または拒否されるとポップアップが閉じます。
Chrome、FF、Safari、Opera でテスト済み。一貫した行動。
Chrome で空白のリダイレクト ページをデバッグすると、次の 2 つのエラーが発生します。
1) Unsafe JavaScript attempt to access frame with URL http://something from frame with URL https://something. Domains, protocols and ports must match.
(http x https に注意してください...)
2)window_comm.php:7Uncaught TypeError: Cannot call method '_recv' of undefined
関連するコードは次のとおりです。
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'my-app-id',
status : true,
channelURL : 'http://localhost:3000/channel.html',
cookie : true,
oauth : true,
xfbml : true
});
FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/pt_BR/all.js"
fjs.parentNode.insertBefore(js, fjs);
}
(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-login-button" data-show-faces="true" data-width="400" data-max-rows="1" perms="offline_access"></div>
これに光を当ててくれてありがとう...私を狂わせる!=(
編集: http から https にリダイレクトしているため、Facebook のバグでしょうか?