use of com.facebook.AccessToken in project facebook-android-sdk by facebook.
the class DeviceAuthMethodHandler method onSuccess.
public void onSuccess(String accessToken, String applicationId, String userId, Collection<String> permissions, Collection<String> declinedPermissions, AccessTokenSource accessTokenSource, Date expirationTime, Date lastRefreshTime) {
AccessToken token = new AccessToken(accessToken, applicationId, userId, permissions, declinedPermissions, accessTokenSource, expirationTime, lastRefreshTime);
LoginClient.Result outcome = LoginClient.Result.createTokenResult(loginClient.getPendingRequest(), token);
loginClient.completeAndValidate(outcome);
}
use of com.facebook.AccessToken in project facebook-android-sdk by facebook.
the class GetTokenLoginMethodHandler method onComplete.
void onComplete(final LoginClient.Request request, final Bundle result) {
AccessToken token = createAccessTokenFromNativeLogin(result, AccessTokenSource.FACEBOOK_APPLICATION_SERVICE, request.getApplicationId());
LoginClient.Result outcome = LoginClient.Result.createTokenResult(loginClient.getPendingRequest(), token);
loginClient.completeAndValidate(outcome);
}
use of com.facebook.AccessToken in project facebook-android-sdk by facebook.
the class UserSettingsFragment method fetchUserInfo.
private void fetchUserInfo() {
final AccessToken accessToken = AccessToken.getCurrentAccessToken();
if (accessToken != null) {
GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject me, GraphResponse response) {
user = me;
updateUI();
}
});
Bundle parameters = new Bundle();
parameters.putString(FIELDS, REQUEST_FIELDS);
request.setParameters(parameters);
GraphRequest.executeBatchAsync(request);
} else {
user = null;
}
}
use of com.facebook.AccessToken in project facebook-android-sdk by facebook.
the class UserSettingsFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
accessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
fetchUserInfo();
updateUI();
}
};
callbackManager = CallbackManager.Factory.create();
}
use of com.facebook.AccessToken in project facebook-android-sdk by facebook.
the class LoginClientTest method testResultParceling.
@Test
public void testResultParceling() {
LoginClient.Request request = new LoginClient.Request(LoginBehavior.WEB_ONLY, null, DefaultAudience.EVERYONE, null, null);
request.setRerequest(true);
AccessToken token1 = new AccessToken("Token2", "12345", "1000", null, null, null, null, null);
LoginClient.Result result = new LoginClient.Result(request, LoginClient.Result.Code.SUCCESS, token1, "error 1", "123");
LoginClient.Result unparceledResult = TestUtils.parcelAndUnparcel(result);
LoginClient.Request unparceledRequest = unparceledResult.request;
assertEquals(LoginBehavior.WEB_ONLY, unparceledRequest.getLoginBehavior());
assertEquals(new HashSet<String>(), unparceledRequest.getPermissions());
assertEquals(DefaultAudience.EVERYONE, unparceledRequest.getDefaultAudience());
assertEquals(null, unparceledRequest.getApplicationId());
assertEquals(null, unparceledRequest.getAuthId());
assertTrue(unparceledRequest.isRerequest());
assertEquals(LoginClient.Result.Code.SUCCESS, unparceledResult.code);
assertEquals(token1, unparceledResult.token);
assertEquals("error 1", unparceledResult.errorMessage);
assertEquals("123", unparceledResult.errorCode);
}
Aggregations