void forceExtendAccessToken(boolean forceExtendAccessToken) {
   AccessToken currentToken = getTokenInfo();
   setTokenInfo(
       new AccessToken(
           currentToken.getToken(),
           new Date(),
           currentToken.getPermissions(),
           AccessTokenSource.TEST_USER,
           new Date(0)));
   setLastAttemptedTokenExtendDate(new Date(0));
 }
  @UnityCallable
  public static void RefreshCurrentAccessToken(String paramsStr) {
    FB.LogMethodCall("RefreshCurrentAccessToken", paramsStr);

    UnityParams unityParams = UnityParams.parse(paramsStr);
    final UnityMessage unityMessage = new UnityMessage("OnRefreshCurrentAccessTokenComplete");
    if (unityParams.hasString("callback_id")) {
      unityMessage.put("callback_id", unityParams.getString("callback_id"));
    }

    AccessToken.refreshCurrentAccessTokenAsync(
        new AccessToken.AccessTokenRefreshCallback() {
          @Override
          public void OnTokenRefreshed(AccessToken accessToken) {
            FBLogin.addLoginParametersToMessage(unityMessage, accessToken, null);
            unityMessage.send();
          }

          @Override
          public void OnTokenRefreshFailed(FacebookException e) {
            unityMessage.sendError(e.getMessage());
          }
        });

    AppLinkData.fetchDeferredAppLinkData(
        getUnityActivity(),
        new AppLinkData.CompletionHandler() {
          @Override
          public void onDeferredAppLinkDataFetched(AppLinkData appLinkData) {
            FB.addAppLinkToMessage(unityMessage, appLinkData);
            unityMessage.send();
          }
        });
  }
  private void finishAuthWithTestAccount(TestAccount testAccount) {
    testAccountId = testAccount.getId();

    AccessToken accessToken =
        AccessToken.createFromString(
            testAccount.getAccessToken(), requestedPermissions, AccessTokenSource.TEST_USER);
    finishAuthOrReauth(accessToken, null);
  }
  @SmallTest
  @MediumTest
  @LargeTest
  public void testCacheRoundtrip() {
    ArrayList<String> permissions = Utility.arrayList("stream_publish", "go_outside_and_play");
    String token = "AnImaginaryTokenValue";
    Date later = TestUtils.nowPlusSeconds(60);
    Date earlier = TestUtils.nowPlusSeconds(-60);

    SharedPreferencesTokenCachingStrategy cache =
        new SharedPreferencesTokenCachingStrategy(getContext());
    cache.clear();

    Bundle bundle = new Bundle();
    TokenCachingStrategy.putToken(bundle, token);
    TokenCachingStrategy.putExpirationDate(bundle, later);
    TokenCachingStrategy.putSource(bundle, AccessTokenSource.FACEBOOK_APPLICATION_NATIVE);
    TokenCachingStrategy.putLastRefreshDate(bundle, earlier);
    TokenCachingStrategy.putPermissions(bundle, permissions);

    cache.save(bundle);
    bundle = cache.load();

    AccessToken accessToken = AccessToken.createFromCache(bundle);
    TestUtils.assertSamePermissions(permissions, accessToken);
    assertEquals(token, accessToken.getToken());
    assertEquals(AccessTokenSource.FACEBOOK_APPLICATION_NATIVE, accessToken.getSource());
    assertTrue(!accessToken.isInvalid());

    Bundle cachedBundle = accessToken.toCacheBundle();
    TestUtils.assertEqualContents(bundle, cachedBundle);
  }
  public static VirtualFile createTestProjectStructure(
      String tempName,
      Module module,
      String rootPath,
      Collection<File> filesToDelete,
      boolean addProjectRoots)
      throws IOException {
    File dir = FileUtil.createTempDirectory(tempName, null, false);
    filesToDelete.add(dir);

    VirtualFile vDir =
        LocalFileSystem.getInstance()
            .refreshAndFindFileByPath(dir.getCanonicalPath().replace(File.separatorChar, '/'));
    assert vDir != null && vDir.isDirectory() : dir;
    PlatformTestCase.synchronizeTempDirVfs(vDir);

    EdtTestUtil.runInEdtAndWait(
        () -> {
          AccessToken token = WriteAction.start();
          try {
            if (rootPath != null) {
              VirtualFile vDir1 =
                  LocalFileSystem.getInstance()
                      .findFileByPath(rootPath.replace(File.separatorChar, '/'));
              if (vDir1 == null) {
                throw new Exception(rootPath + " not found");
              }
              VfsUtil.copyDirectory(null, vDir1, vDir, null);
            }

            if (addProjectRoots) {
              addSourceContentToRoots(module, vDir);
            }
          } finally {
            token.finish();
          }
        });
    return vDir;
  }
        /**
         * Called when OAuth authentication has been finalized and an Access Token and Access Token
         * Secret have been provided
         *
         * @param accessToken The access token to use to do REST calls
         */
        @Override
        public void gotOAuthAccessToken(AccessToken accessToken) {
          SoomlaUtils.LogDebug(TAG, "login/onComplete");

          twitter.setOAuthAccessToken(accessToken);

          // Keep in storage for logging in without web-authentication
          KeyValueStorage.setValue(
              getTwitterStorageKey(TWITTER_OAUTH_TOKEN), accessToken.getToken());
          KeyValueStorage.setValue(
              getTwitterStorageKey(TWITTER_OAUTH_SECRET), accessToken.getTokenSecret());

          // Keep screen name since Twitter4J does not have it when
          // logging in using authenticated tokens
          KeyValueStorage.setValue(
              getTwitterStorageKey(TWITTER_SCREEN_NAME), accessToken.getScreenName());

          twitterScreenName = accessToken.getScreenName();

          RefLoginListener.success(RefProvider);

          clearListener(ACTION_LOGIN);
        }