使用Scribe登录时无法重定向正确的页面

时间:2014-11-12 08:46:15

标签: java facebook oauth-2.0 scribe

我想从脸书中获取用户的联系人列表,因为我正在使用以下代码

public class FacebookLogin {
    private static final String NETWORK_NAME = "Facebook";
    private static final String PROTECTED_RESOURCE_URL = "https://graph.facebook.com/me";
    private static final Token EMPTY_TOKEN = null;
    OAuthService service = new ServiceBuilder()
            .provider(FacebookApi.class)
            .apiKey("Key")
            .apiSecret("Pass")
            .callback("http://localhost:8082/tt/FetchFacebookContact")
            .build();
        public String LoginToFacebook() {

        System.out.println("=== " + NETWORK_NAME + "'s OAuth Workflow ===");
        System.out.println();

        // Obtain the Authorization URL
        System.out.println("Fetching the Authorization URL...");
        setUrl(service.getAuthorizationUrl(EMPTY_TOKEN));
        System.out.println("Got the Authorization URL!");
        System.out.println("Now go and authorize Scribe here:");
        System.out.println(getUrl());

        return "redirect";
    }

执行此代码后,页面将重定向到

https://www.facebook.com/dialog/oauth?client_id=23343&redirect_uri=
http%3A%2F%2Flocalhost%3A8082%2Ftt%2FFetchFacebookContact

此页面正在显示

Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.

here

中选取示例

如何才能获得正确的页面。

1 个答案:

答案 0 :(得分:0)

我发现这个问题是因为我使用http://localhost:8082/tt/FetchFacebookContact来表示.callback()。 用实际的服务器URL替换它们时,它正在工作。