Not able to redirect proper page while using login with Scribe

108 views Asked by At

I would like to fetch user's contact list from face book for that I am using following code

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";
    }

After executing this code Page is redirected to

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

This page is showing

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.

Taken example from here

How can I get correct page.

1

There are 1 answers

0
xrcwrn On BEST ANSWER

Well I found this problem was due to that I was using http://localhost:8082/tt/FetchFacebookContact for .callback(). While replacing these with actual server url it is working.