【问题标题】:Are facebook App ID and App Secret specific for every user that uses facebook connectfacebook App ID 和 App Secret 是否特定于使用 facebook connect 的每个用户
【发布时间】:2013-04-09 15:36:38
【问题描述】:

大家好,我在使用 facebook connect 时遇到问题,我正在使用这些 API 让用户使用他们的 facebook 帐户登录到我的 Web 应用程序,作为上一步,我从 developers.facebook 获得了一个 App ID 和 APP Secret,即问题是登录不会验证任何帐户,除了我在制作 App ID 和 App Secret 时使用的帐户,请帮助我理解这些问题

注意:我使用这些 tutorials 将我的 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 "";
    }
}
}

【问题讨论】:

    标签: facebook servlets jsf-2


    【解决方案1】:

    回答标题中的问题 -
    不,任何用户的应用程序 ID 和密码都是相同的。

    这里的问题(我假设)是您的应用程序处于沙盒模式。禁用该模式,一切正常。

    沙盒模式用于应用程序开发期间,只有应用程序设置的“角色”部分中列出的用户才能访问应用程序。

    【讨论】:

    • 我禁用了沙盒模式,但它仍然坚持只验证我用来制作 App ID 的帐户!我真的很惊讶
    • @jav - 只有某些 用户 无法执行任务时的问题通常与沙盒模式设置有关。我能想象的唯一另一个问题是你的代码有错误。但这听起来不太可能,因为您说它确实适用于创建应用程序的帐户。您能否在处理身份验证过程的相关代码上方添加您的问题?
    • 我正在使用我帖子中提到的教程中的应用程序
    • 您的服务器在您的计算机上吗?其他用户能否访问您的服务器?
    • 不,我只有他们的用户名和密码来测试应用程序
    猜你喜欢
    • 1970-01-01
    • 2015-08-26
    • 1970-01-01
    • 1970-01-01
    • 2011-01-17
    • 2014-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多