use of com.facebook.AccessToken in project facebook-android-sdk by facebook.
the class LoginManagerTest method createSuccessResultIntent.
private Intent createSuccessResultIntent() {
Intent intent = new Intent();
Set<String> permissions = Sets.newSet("public_profile", "user_friends");
LoginClient.Request request = new LoginClient.Request(null, permissions, null, null, null);
AccessToken accessToken = createAccessToken();
LoginClient.Result result = LoginClient.Result.createTokenResult(request, accessToken);
intent.putExtra(LoginFragment.RESULT_KEY, result);
return intent;
}
use of com.facebook.AccessToken in project facebook-android-sdk by facebook.
the class LoginManagerTest method testLogInWithReadAndAccessTokenCreatesReauthRequest.
@Test
public void testLogInWithReadAndAccessTokenCreatesReauthRequest() {
AccessToken accessToken = createAccessToken();
stub(method(AccessToken.class, "getCurrentAccessToken")).toReturn(accessToken);
LoginManager loginManager = new LoginManager();
loginManager.logInWithReadPermissions(mockActivity, Arrays.asList("public_profile", "user_friends"));
int loginRequestCode = CallbackManagerImpl.RequestCodeOffset.Login.toRequestCode();
verify(mockActivity, times(1)).startActivityForResult(any(Intent.class), eq(loginRequestCode));
}
use of com.facebook.AccessToken in project facebook-android-sdk by facebook.
the class LoginResultTest method testDeniedPermissions.
@Test
public void testDeniedPermissions() {
LoginClient.Request request = createRequest(LIKES_EMAIL_SET, true);
AccessToken accessToken = createAccessToken(EMAIL_SET, new HashSet<String>());
LoginResult result = LoginManager.computeLoginResult(request, accessToken);
assertEquals(accessToken, result.getAccessToken());
assertEquals(EMAIL_SET, result.getRecentlyGrantedPermissions());
assertEquals(new HashSet<String>() {
{
add("user_likes");
}
}, result.getRecentlyDeniedPermissions());
}
use of com.facebook.AccessToken in project facebook-android-sdk by facebook.
the class WebViewLoginMethodHandlerTest method testFromSSOWithExpiresString.
@Test
public void testFromSSOWithExpiresString() {
List<String> permissions = Utility.arrayList("stream_publish", "go_outside_and_play");
String token = "AnImaginaryTokenValue";
Intent intent = new Intent();
intent.putExtra("access_token", token);
intent.putExtra("expires_in", "60");
intent.putExtra("extra_extra", "Something unrelated");
intent.putExtra("signed_request", SIGNED_REQUEST_STR);
AccessToken accessToken = LoginMethodHandler.createAccessTokenFromWebBundle(permissions, intent.getExtras(), AccessTokenSource.FACEBOOK_APPLICATION_WEB, "1234");
TestUtils.assertSamePermissions(permissions, accessToken);
assertEquals(token, accessToken.getToken());
assertEquals(AccessTokenSource.FACEBOOK_APPLICATION_WEB, accessToken.getSource());
assertTrue(!accessToken.isExpired());
}
use of com.facebook.AccessToken in project facebook-android-sdk by facebook.
the class CustomTabLoginMethodHandlerTest method testCustomTabHandlesSuccess.
@Test
public void testCustomTabHandlesSuccess() {
final Bundle bundle = new Bundle();
bundle.putString("access_token", ACCESS_TOKEN);
bundle.putString("expires_in", String.format("%d", EXPIRES_IN_DELTA));
bundle.putString("code", "Something else");
bundle.putString("signed_request", SIGNED_REQUEST_STR);
handler.onComplete(request, bundle, null);
final ArgumentCaptor<LoginClient.Result> resultArgumentCaptor = ArgumentCaptor.forClass(LoginClient.Result.class);
verify(mockLoginClient, times(1)).completeAndValidate(resultArgumentCaptor.capture());
final LoginClient.Result result = resultArgumentCaptor.getValue();
assertNotNull(result);
assertEquals(LoginClient.Result.Code.SUCCESS, result.code);
final AccessToken token = result.token;
assertNotNull(token);
assertEquals(ACCESS_TOKEN, token.getToken());
assertDateDiffersWithinDelta(new Date(), token.getExpires(), EXPIRES_IN_DELTA * 1000, 1000);
TestUtils.assertSamePermissions(PERMISSIONS, token.getPermissions());
}
Aggregations