Added scope to facebook api
This commit is contained in:
1 parent
2112d3d8a9
commit
592b1b5fdd
2 files changed
+14
-1
No files matched your search
@@ -47,3 +47,4 @@
|
||||
|
||||
[1.2]
|
||||
* REFACTOR: Moved scope inside OAuthConfig (breaks backwards compatibility)
|
||||
* FEATURE: Added scopes to Facebook 2.0 Api
|
||||
@@ -1,11 +1,14 @@
|
||||
package org.scribe.builder.api;
|
||||
|
||||
import org.scribe.model.*;
|
||||
|
||||
import org.scribe.utils.*;
|
||||
import static org.scribe.utils.URLUtils.*;
|
||||
|
||||
public class FacebookApi extends DefaultApi20
|
||||
{
|
||||
private static final String AUTHORIZE_URL = "https://www.facebook.com/dialog/oauth?client_id=%s&redirect_uri=%s";
|
||||
private static final String SCOPED_AUTHORIZE_URL = AUTHORIZE_URL + "&scope=%s";
|
||||
|
||||
@Override
|
||||
public String getAccessTokenEndpoint()
|
||||
@@ -17,6 +20,15 @@ public class FacebookApi extends DefaultApi20
|
||||
public String getAuthorizationUrl(OAuthConfig config)
|
||||
{
|
||||
Preconditions.checkValidUrl(config.getCallback(), "Must provide a valid url as callback. Facebook does not support OOB");
|
||||
return String.format(AUTHORIZE_URL, config.getApiKey(), URLUtils.formURLEncode(config.getCallback()));
|
||||
|
||||
// Append scope if present
|
||||
if(config.hasScope())
|
||||
{
|
||||
return String.format(SCOPED_AUTHORIZE_URL, formURLEncode(config.getCallback()), formURLEncode(config.getScope()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format(AUTHORIZE_URL, config.getApiKey(), formURLEncode(config.getCallback()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user