package com.github.scribejava.apis;

import com.github.scribejava.core.builder.api.DefaultApi20;
import com.github.scribejava.core.model.OAuthConfig;
import com.github.scribejava.core.model.OAuthConstants;
import com.github.scribejava.core.utils.OAuthEncoder;
import com.github.scribejava.core.utils.Preconditions;

public class FacebookApi extends DefaultApi20 {

    private static final String AUTHORIZE_URL
            = "https://www.facebook.com/v2.2/dialog/oauth?client_id=%s&redirect_uri=%s";

    private FacebookApi() {
    }

    private static class InstanceHolder {
        private static final FacebookApi INSTANCE = new FacebookApi();
    }

    public static FacebookApi instance() {
        return InstanceHolder.INSTANCE;
    }

    @Override
    public String getAccessTokenEndpoint() {
        return "https://graph.facebook.com/v2.2/oauth/access_token";
    }

    @Override
    public String getAuthorizationUrl(OAuthConfig config) {
        Preconditions.checkValidUrl(config.getCallback(),
                "Must provide a valid url as callback. Facebook does not support OOB");
        final StringBuilder sb = new StringBuilder(String.format(AUTHORIZE_URL, config.getApiKey(),
                OAuthEncoder.encode(config.getCallback())));
        if (config.hasScope()) {
            sb.append('&').append(OAuthConstants.SCOPE).append('=').append(OAuthEncoder.encode(config.getScope()));
        }

        final String state = config.getState();
        if (state != null) {
            sb.append('&').append(OAuthConstants.STATE).append('=').append(OAuthEncoder.encode(state));
        }
        return sb.toString();
    }
}

@@ -90,16 +90,148 @@
 tApi20;%0A
+import com.github.scribejava.core.extractors.AccessTokenExtractor;%0Aimport com.github.scribejava.core.extractors.JsonTokenExtractor;%0A
 import c
@@ -441,16 +441,49 @@
 tions;%0A%0A
+/***%0A * Facebook v2.5 API%0A *%0A */%0A
 public c
@@ -612,17 +612,17 @@
 .com/v2.
-2
+5
 /dialog/
@@ -896,32 +896,155 @@
 NSTANCE;%0A    %7D%0A%0A
+    @Override%0A    public AccessTokenExtractor getAccessTokenExtractor() %7B%0A%0A        return new JsonTokenExtractor();%0A    %7D%0A%0A
     @Override%0A  
@@ -1132,17 +1132,17 @@
 .com/v2.
-2
+5
 /oauth/a

Upgrade to Facebook API Version 2.5.