11

この問題は長い間私を悩ませてきましたが、解決策が見つからないようです。Facebook 開発者パネルのすべての設定、サイト URL、アプリ ドメイン、OAuth URL が正しく構成されています。

iPhone でアプリを実行し (iTunes からインストールしました)、認証ボタンをクリックすると、次の画面が表示されます。

ここに画像の説明を入力

ただし、ログインした後、自分のページにリダイレクトされるのではなく、空白の画面が表示されmain.htmlます。

OpenFBプラグインを Parse および Facebook Graph API と共に使用して、ユーザー データを認証および保存しています。ログイン コードは次のとおりです。

login.html:

$('.facebookLogin').click(function(){
  Parse.User.logOut(); // log current user out before logging in 
  login();
});

function login() {
  openFB.login(function(response) {
    if(response.status === 'connected') {

      console.log('Facebook login succeeded');

      Parse.FacebookUtils.logIn("email", { // permission request to use email
        success: function(user) {
          if (!user.existed()) {
             FB.api('/me', function(response) {
                var firstName = response.first_name;
                var lastName = response.last_name;
                var email = response.email; 
                var user_id = response.id;

                user.set("firstName",firstName);
                user.set("lastName",lastName);
                user.set("email",email);
                user.save();
             }); 
             window.location.href= "main.html";
          } 
          else {
             window.location.href= "main.html";
          } 
        }, 
        error: function(user, error) {
          alert("User cancelled the Facebook login or did not fully authorize.");
        }
     });  
    } 
    else {
      alert('Facebook login failed: ' + response.error);
    }
  }, {scope: 'email'}); 
} 

oauthcallback.html:

<html>
<body>
<script>
   // redirects to main page
   window.location.href= "main.html";
</script>
</body>
</html>

注: とをパネルの有効な OAuth リダイレクト URI リストに追加しましたmain.htmllogin.htmloauthcallback.html

4

1 に答える 1