当前位置: 首页>>代码示例>>Java>>正文


Java AccessToken.refreshCurrentAccessTokenAsync方法代码示例

本文整理汇总了Java中com.facebook.AccessToken.refreshCurrentAccessTokenAsync方法的典型用法代码示例。如果您正苦于以下问题:Java AccessToken.refreshCurrentAccessTokenAsync方法的具体用法?Java AccessToken.refreshCurrentAccessTokenAsync怎么用?Java AccessToken.refreshCurrentAccessTokenAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.AccessToken的用法示例。


在下文中一共展示了AccessToken.refreshCurrentAccessTokenAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: refreshFacebookCredentials

import com.facebook.AccessToken; //导入方法依赖的package包/类
/**
 * Refresh cognito credentials based on identity token previously obtained from Facebook
 * @param onCompletion a runnable that will be executed once the credentials have been successfully renewed
 */
private void refreshFacebookCredentials(Runnable onCompletion) {

    Log.v(TAG, "Will try to refresh Facebook token as session has expired...");

    final AccessToken accessToken = AccessToken.getCurrentAccessToken();

    if (!accessToken.isExpired()) {

        Log.v(TAG, String.format("  -> Facebook token is not expired (expiration %s)...", SimpleDateFormat.getInstance().format(accessToken.getExpires())));
        String token = accessToken.getToken();

        Map<String, String> logins = new HashMap<>();
        logins.put(FACEBOOK_LOGIN, token);

        Log.v(TAG, "  -> will refresh login for " + FACEBOOK_LOGIN);

        // Refreshing session credentials (must be asynchronous)...
        new RefreshTokenTask(onCompletion).execute(logins);

        // We use the opportunity to refresh the Facebook token
        Date now = new Date();
        if (accessToken.getLastRefresh().getTime() < (now.getTime() - 7 * 86400)) {
            Log.v(TAG, "  -> triggering async facebook token refresh");
            AccessToken.refreshCurrentAccessTokenAsync();
        }

    } else {

        Log.v(TAG, String.format("  -> Facebook token is expired (expiration %s)...", SimpleDateFormat.getInstance().format(accessToken.getExpires())));
        //User has to sign in to refresh an elapsed facebook token
        // TODO onCompletion is ignored (should be dealt with in onActivityResult)
        Intent intent = new Intent(this, SignInActivity.class);
        this.startActivity(intent);

    }
}
 
开发者ID:ironbird-software,项目名称:aws-cognito-sync-issues,代码行数:41,代码来源:MainActivity.java

示例2: refreshFacebookAccessToken

import com.facebook.AccessToken; //导入方法依赖的package包/类
/**
 * Refresh Facebook Access Token.
 * According to Facebook's docs this may or may not extend the expiration date.
 * Must be called from the UI Thread.
 */
public static void refreshFacebookAccessToken() {
    AccessToken.refreshCurrentAccessTokenAsync();
}
 
开发者ID:Popdeem,项目名称:Popdeem-SDK-Android,代码行数:9,代码来源:PDSocialUtils.java


注:本文中的com.facebook.AccessToken.refreshCurrentAccessTokenAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。