Class DefaultInstagramLoginClient
- java.lang.Object
-
- com.restfb.DefaultFacebookClient
-
- com.restfb.DefaultInstagramLoginClient
-
- All Implemented Interfaces:
FacebookClient
public class DefaultInstagramLoginClient extends DefaultFacebookClient
InstagramLoginClient is the default implementation of the Instagram API with Instagram Login.This client is used to use a instagram Login to get a access token, extended access token and so on for the Instagram API.
Don't use the client if you are planning to use the Facebbok Login to work with the Instagram API.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.restfb.DefaultFacebookClient
DefaultFacebookClient.Requestor
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
ACCESS_TOKEN_PARAM_NAME
Reserved access token parameter name.protected static String
APP_SECRET_PROOF_PARAM_NAME
Reserved application secret proof parameter name.protected static String
FORMAT_PARAM_NAME
Reserved "result format" parameter name.protected JsonMapper
jsonMapper
Handles mapping Facebook response JSON to Java objects.protected static String
METHOD_PARAM_NAME
Reserved method override parameter name.protected WebRequestor
webRequestor
HandlesGET
s andPOST
s to the Facebook API endpoint.-
Fields inherited from class com.restfb.DefaultFacebookClient
accessToken, accessTokenInHeader, ALGORITHM, apiVersion, APP_ID, APP_SECRET, appSecret, CANNOT_EXTRACT_ACCESS_TOKEN_MESSAGE, CLIENT_ID, CODE, CONNECTION, CONNECTION_TYPE, GRANT_TYPE, httpDeleteFallback, IDS_PARAM_NAME, PARAM_CLIENT_SECRET, PATH_OAUTH_ACCESS_TOKEN, REDIRECT_URI, SCOPE
-
-
Constructor Summary
Constructors Constructor Description DefaultInstagramLoginClient(Version version)
DefaultInstagramLoginClient(String accessToken, Version apiVersion)
DefaultInstagramLoginClient(String accessToken, WebRequestor webRequestor, JsonMapper jsonMapper, Version apiVersion)
DefaultInstagramLoginClient(String accessToken, String appSecret, Version apiVersion)
DefaultInstagramLoginClient(String accessToken, String appSecret, WebRequestor webRequestor, JsonMapper jsonMapper, Version apiVersion)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
createBaseUrlForEndpoint(String apiCall, boolean hasAttachment, boolean hasReel)
FacebookClient
createClientWithAccessToken(String accessToken)
creates a newFacebookClient
from an old one.String
getLoginDialogUrl(String appId, String redirectUri, ScopeBuilder scope, Parameter... parameters)
generates the login dialog urlString
getLoginDialogUrl(String appId, String redirectUri, ScopeBuilder scope, String state, Parameter... parameters)
generates the login dialog urlAccessToken
obtainExtendedAccessToken(String appId, String appSecret)
Convenience method which invokesFacebookClient.obtainExtendedAccessToken(String, String, String)
with the current access token.AccessToken
obtainRefreshedExtendedAccessToken()
Obtain a refreshed Instagram extended access token.AccessToken
obtainUserAccessToken(String clientId, String clientSecret, String redirectUri, String code)
Obtains an access token which can be used to perform Graph API operations on behalf of a user.protected Parameter[]
parametersWithAdditionalParameter(Parameter parameter, Parameter... parameters)
Appends the givenparameter
to the givenparameters
array.protected String
urlEncodedValueForParameterName(String name, String value)
Gets the URL-encoded version of the givenvalue
for the parameter namedname
.protected void
verifyParameterLegality(Parameter... parameters)
Verifies that the provided parameter names don't collide with the ones we internally pass along to Facebook.-
Methods inherited from class com.restfb.DefaultFacebookClient
convertSessionKeysToAccessTokens, createEndpointForApiCall, debugToken, deleteObject, executeBatch, executeBatch, executeBatch, fetchConnection, fetchConnectionPage, fetchDeviceCode, fetchObject, fetchObjects, getAccessTokenFromResponse, getFacebookEndpointUrls, getFacebookExceptionGenerator, getFacebookGraphEndpointUrl, getFacebookGraphVideoEndpointUrl, getFacebookReelsUploadEndpointUrl, getGenericLoginDialogUrl, getJsonMapper, getLogoutUrl, getWebRequestor, isHttpDeleteFallback, makeRequest, makeRequest, makeRequest, makeRequestAndProcessResponse, obtainAppAccessToken, obtainAppSecretProof, obtainDeviceAccessToken, obtainExtendedAccessToken, parseSignedRequest, publish, publish, publish, publish, setFacebookEndpointUrls, setFacebookExceptionGenerator, setHeaderAuthorization, setHttpDeleteFallback, toParameterString, toParameterString, urlDecodeSignedRequestToken, verifySignedRequest
-
-
-
-
Field Detail
-
webRequestor
protected WebRequestor webRequestor
HandlesGET
s andPOST
s to the Facebook API endpoint.
-
jsonMapper
protected JsonMapper jsonMapper
Handles mapping Facebook response JSON to Java objects.
-
METHOD_PARAM_NAME
protected static final String METHOD_PARAM_NAME
Reserved method override parameter name.- See Also:
- Constant Field Values
-
FORMAT_PARAM_NAME
protected static final String FORMAT_PARAM_NAME
Reserved "result format" parameter name.- See Also:
- Constant Field Values
-
ACCESS_TOKEN_PARAM_NAME
protected static final String ACCESS_TOKEN_PARAM_NAME
Reserved access token parameter name.- See Also:
- Constant Field Values
-
APP_SECRET_PROOF_PARAM_NAME
protected static final String APP_SECRET_PROOF_PARAM_NAME
Reserved application secret proof parameter name.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultInstagramLoginClient
public DefaultInstagramLoginClient(Version version)
-
DefaultInstagramLoginClient
public DefaultInstagramLoginClient(String accessToken, Version apiVersion)
-
DefaultInstagramLoginClient
public DefaultInstagramLoginClient(String accessToken, String appSecret, Version apiVersion)
-
DefaultInstagramLoginClient
public DefaultInstagramLoginClient(String accessToken, WebRequestor webRequestor, JsonMapper jsonMapper, Version apiVersion)
-
DefaultInstagramLoginClient
public DefaultInstagramLoginClient(String accessToken, String appSecret, WebRequestor webRequestor, JsonMapper jsonMapper, Version apiVersion)
-
-
Method Detail
-
getLoginDialogUrl
public String getLoginDialogUrl(String appId, String redirectUri, ScopeBuilder scope, String state, Parameter... parameters)
Description copied from interface:FacebookClient
generates the login dialog url- Specified by:
getLoginDialogUrl
in interfaceFacebookClient
- Overrides:
getLoginDialogUrl
in classDefaultFacebookClient
- Parameters:
appId
- The ID of your app, found in your app's dashboard.redirectUri
- The URL that you want to redirect the person logging in back to. This URL will capture the response from the Login Dialog. If you are using this in a webview within a desktop app, this must be set tohttps://www.facebook.com/connect/login_success.html
.scope
- List of Permissions to request from the person using your app.state
- The state parameter is used to prevent CSRF attacks.parameters
- List of additional parameters- Returns:
- the login dialog url
-
getLoginDialogUrl
public String getLoginDialogUrl(String appId, String redirectUri, ScopeBuilder scope, Parameter... parameters)
Description copied from interface:FacebookClient
generates the login dialog url- Specified by:
getLoginDialogUrl
in interfaceFacebookClient
- Overrides:
getLoginDialogUrl
in classDefaultFacebookClient
- Parameters:
appId
- The ID of your app, found in your app's dashboard.redirectUri
- The URL that you want to redirect the person logging in back to. This URL will capture the response from the Login Dialog. If you are using this in a webview within a desktop app, this must be set tohttps://www.facebook.com/connect/login_success.html
.scope
- List of Permissions to request from the person using your app.parameters
- List of additional parameters- Returns:
- the login dialog url
-
obtainUserAccessToken
public AccessToken obtainUserAccessToken(String clientId, String clientSecret, String redirectUri, String code)
Description copied from interface:FacebookClient
Obtains an access token which can be used to perform Graph API operations on behalf of a user.See Access Tokens.
- Specified by:
obtainUserAccessToken
in interfaceFacebookClient
- Overrides:
obtainUserAccessToken
in classDefaultFacebookClient
- Parameters:
clientId
- The ID of the app for which you'd like to obtain an access token.clientSecret
- The secret for the app for which you'd like to obtain an access token.redirectUri
- The redirect URI which was used to obtain theverificationCode
.code
- The verification code in the Graph API callback to the redirect URI.- Returns:
- The access token for the user identified by
appId
,appSecret
,redirectUri
andverificationCode
. - See Also:
FacebookClient.obtainUserAccessToken(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
-
obtainExtendedAccessToken
public AccessToken obtainExtendedAccessToken(String appId, String appSecret)
Description copied from interface:FacebookClient
Convenience method which invokesFacebookClient.obtainExtendedAccessToken(String, String, String)
with the current access token.- Specified by:
obtainExtendedAccessToken
in interfaceFacebookClient
- Overrides:
obtainExtendedAccessToken
in classDefaultFacebookClient
- Parameters:
appId
- The ID of the app for which you'd like to obtain an extended access token.appSecret
- The secret for the app for which you'd like to obtain an extended access token.- Returns:
- An extended access token for the given
accessToken
. - See Also:
FacebookClient.obtainExtendedAccessToken(java.lang.String, java.lang.String)
-
createClientWithAccessToken
public FacebookClient createClientWithAccessToken(String accessToken)
Description copied from interface:FacebookClient
creates a newFacebookClient
from an old one.App secret and api version are taken from the original client.
- Specified by:
createClientWithAccessToken
in interfaceFacebookClient
- Overrides:
createClientWithAccessToken
in classDefaultFacebookClient
- Parameters:
accessToken
- this accesstoken is used for the new client- Returns:
- a new Facebookclient
-
obtainRefreshedExtendedAccessToken
public AccessToken obtainRefreshedExtendedAccessToken()
Description copied from interface:FacebookClient
Obtain a refreshed Instagram extended access token.This method is used to refresh an existing Instagram extended access token. Extended access tokens expire after a certain period of time, and this method allows you to obtain a new one using the refresh token provided with the original extended access token.
- Specified by:
obtainRefreshedExtendedAccessToken
in interfaceFacebookClient
- Overrides:
obtainRefreshedExtendedAccessToken
in classDefaultFacebookClient
- Returns:
- A new
AccessToken
object containing the refreshed access token, expiration time, and token type.
-
createBaseUrlForEndpoint
protected String createBaseUrlForEndpoint(String apiCall, boolean hasAttachment, boolean hasReel)
- Overrides:
createBaseUrlForEndpoint
in classDefaultFacebookClient
-
parametersWithAdditionalParameter
protected Parameter[] parametersWithAdditionalParameter(Parameter parameter, Parameter... parameters)
Appends the givenparameter
to the givenparameters
array.- Parameters:
parameter
- The parameter value to append.parameters
- The parameters to which the givenparameter
is appended.- Returns:
- A new array which contains both
parameter
andparameters
.
-
urlEncodedValueForParameterName
protected String urlEncodedValueForParameterName(String name, String value)
Gets the URL-encoded version of the givenvalue
for the parameter namedname
.Includes special-case handling for access token parameters where we check if the token is already URL-encoded - if so, we don't encode again. All other parameter types are always URL-encoded.
- Parameters:
name
- The name of the parameter whose value should be URL-encoded and returned.value
- The value of the parameter which should be URL-encoded and returned.- Returns:
- The URL-encoded version of the given
value
.
-
verifyParameterLegality
protected void verifyParameterLegality(Parameter... parameters)
Verifies that the provided parameter names don't collide with the ones we internally pass along to Facebook.- Parameters:
parameters
- The parameters to check.- Throws:
IllegalArgumentException
- If there's a parameter name collision.
-
-