@Override public AccessToken obtainDeviceAccessToken(String code) throws FacebookDeviceTokenCodeExpiredException, FacebookDeviceTokenPendingException, FacebookDeviceTokenDeclinedException, FacebookDeviceTokenSlowdownException { verifyParameterPresence("code", code); if (accessToken == null) { throw new IllegalStateException("access token is required to fetch a device access token"); } try { String response = makeRequest("device/login_status", true, false, null, Parameter.with("type", "device_token"), Parameter.with("code", code)); return getAccessTokenFromResponse(response); } catch (FacebookOAuthException foae) { DeviceTokenExceptionFactory.createFrom(foae); return null; } }
/** * @see com.restfb.FacebookClient#obtainAppAccessToken(java.lang.String, java.lang.String) */ @Override public AccessToken obtainAppAccessToken(String appId, String appSecret) { verifyParameterPresence("appId", appId); verifyParameterPresence("appSecret", appSecret); String response = makeRequest("oauth/access_token", Parameter.with("grant_type", "client_credentials"), Parameter.with("client_id", appId), Parameter.with("client_secret", appSecret)); try { return getAccessTokenFromResponse(response); } catch (Exception t) { throw new FacebookResponseContentException("Unable to extract access token from response.", t); } }
/** * @see com.restfb.FacebookClient#obtainExtendedAccessToken(java.lang.String, java.lang.String, java.lang.String) */ @Override public AccessToken obtainExtendedAccessToken(String appId, String appSecret, String accessToken) { verifyParameterPresence("appId", appId); verifyParameterPresence("appSecret", appSecret); verifyParameterPresence("accessToken", accessToken); String response = makeRequest("/oauth/access_token", false, false, null, Parameter.with("client_id", appId), Parameter.with("client_secret", appSecret), Parameter.with("grant_type", "fb_exchange_token"), Parameter.with("fb_exchange_token", accessToken)); try { return getAccessTokenFromResponse(response); } catch (Exception t) { throw new FacebookResponseContentException("Unable to extract access token from response.", t); } }
/** * @see com.restfb.FacebookClient#obtainUserAccessToken(java.lang.String, java.lang.String, java.lang.String, * java.lang.String) */ @Override public AccessToken obtainUserAccessToken(String appId, String appSecret, String redirectUri, String verificationCode) { verifyParameterPresence("appId", appId); verifyParameterPresence("appSecret", appSecret); verifyParameterPresence("verificationCode", verificationCode); String response = makeRequest("oauth/access_token", Parameter.with("client_id", appId), Parameter.with("client_secret", appSecret), Parameter.with("code", verificationCode), Parameter.with("redirect_uri", redirectUri)); try { return getAccessTokenFromResponse(response); } catch (Exception t) { throw new FacebookResponseContentException("Unable to extract access token from response.", t); } }