1

こんにちは、Facebook 接続に問題があります。これらの API を使用して、ユーザーが Facebook アカウントを使用して Web アプリケーションにログインできるようにしています。前のステップとして、 developers.facebookからアプリ ID と APP シークレットを取得します。問題は、ログインは、アプリ ID とアプリ シークレットを作成するときに使用するアカウント以外のアカウントを認証しません。これらの問題を理解するのを手伝ってください

注: これらのチュートリアルを使用して、Web アプリケーションを Facebook Connect と統合します

より明確にするために、これは jsf の開始ページです (ソース コードは、私の投稿に記載されているリンクから入手できます)。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
</h:head>
<h:body>
    <h1>Login Page</h1>
    <h:form id="loginForm">
        <p:button value="Facebook Connect" href="#{loginPageCode.facebookUrlAuth}" />
        <br/><br/>
        <h:outputText value="#{loginPageCode.userFromSession}"></h:outputText>
    </h:form>
</h:body>

これがマネージド Bean です。

@ManagedBean(name = "loginPageCode")
@SessionScoped
public class LoginPageCode implements Serializable {
private static final long serialVersionUID = -1611162265998907599L;

public String getFacebookUrlAuth() {
    HttpSession session = (HttpSession) FacesContext.getCurrentInstance()
            .getExternalContext().getSession(false);
    String sessionId = session.getId();
    String appId = "3827326728372872";
    String redirectUrl  = "http://localhost:8080/Test/index.sec";
    String returnValue = "https://www.facebook.com/dialog/oauth?client_id="
            + appId + "&redirect_uri=" + redirectUrl
            + "&scope=email,user_birthday&state=" + sessionId;
    System.out.println("Return Value---->"+returnValue);
    return returnValue;
}

public String getUserFromSession() {
    HttpSession session = (HttpSession) FacesContext.getCurrentInstance()
            .getExternalContext().getSession(false);
    String userName = (String) session.getAttribute("FACEBOOK_USER");
    System.out.println("FACEBOOK_USER-->"+userName);
    if (userName != null) {
        return "Hello " + userName;
    } else {
        return "";
    }
}
}
4

1 に答える 1

1

タイトルの質問に答えるには -
いいえ、アプリケーション ID とシークレットはどのユーザーでも同じです。

ここでの問題 (私は推測します) は、アプリケーションがサンドボックス モードであることです。そのモードを無効にすると、すべてが機能するはずです。

サンドボックス モードはアプリケーションの開発中に使用するためのもので、アプリケーション設定の「ロール」セクションにリストされているユーザーのみがアプリケーションにアクセスできます。

于 2013-04-09T15:40:19.527 に答える