Java Code Examples for com.sina.weibo.sdk.auth.Oauth2AccessToken#setUid()

The following examples show how to use com.sina.weibo.sdk.auth.Oauth2AccessToken#setUid() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccessTokenKeeper.java    From SimpleProject with MIT License 5 votes vote down vote up
/**
 * 从 SharedPreferences 读取 Token 信息。
 * 
 * @param context 应用程序上下文环境
 * 
 * @return 返回 Token 对象
 */
public static Oauth2AccessToken readAccessToken(Context context) {
    if (null == context) {
        return null;
    }
    
    Oauth2AccessToken token = new Oauth2AccessToken();
    SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
    token.setUid(pref.getString(KEY_UID, ""));
    token.setToken(pref.getString(KEY_ACCESS_TOKEN, ""));
    token.setRefreshToken(pref.getString(KEY_REFRESH_TOKEN, ""));
    token.setExpiresTime(pref.getLong(KEY_EXPIRES_IN, 0));
    
    return token;
}
 
Example 2
Source File: AccessTokenKeeper.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
/**
 * 从 SharedPreferences 读取 Token 信息。
 * 
 * @param context 应用程序上下文环境
 * 
 * @return 返回 Token 对象
 */
public static Oauth2AccessToken readAccessToken(Context context) {
    if (null == context) {
        return null;
    }
    
    Oauth2AccessToken token = new Oauth2AccessToken();
    SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
    token.setUid(pref.getString(KEY_UID, ""));
    token.setToken(pref.getString(KEY_ACCESS_TOKEN, ""));
    token.setExpiresTime(pref.getLong(KEY_EXPIRES_IN, 0));
    if(token.getToken().equals(""))return null;
    return token;
}
 
Example 3
Source File: AccessTokenKeeper.java    From BiliShare with Apache License 2.0 5 votes vote down vote up
/**
 * 从 SharedPreferences 读取 Token 信息。
 * 
 * @param context 应用程序上下文环境
 * 
 * @return 返回 Token 对象
 */
public static Oauth2AccessToken readAccessToken(Context context) {
    if (null == context) {
        return null;
    }
    
    Oauth2AccessToken token = new Oauth2AccessToken();
    SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
    token.setUid(pref.getString(KEY_UID, ""));
    token.setToken(pref.getString(KEY_ACCESS_TOKEN, ""));
    token.setRefreshToken(pref.getString(KEY_REFRESH_TOKEN, ""));
    token.setExpiresTime(pref.getLong(KEY_EXPIRES_IN, 0));
    
    return token;
}
 
Example 4
Source File: AccessTokenKeeper.java    From ChinaShare with MIT License 5 votes vote down vote up
/**
 * 从 SharedPreferences 读取 Token 信息。
 * 
 * @param context 应用程序上下文环境
 * 
 * @return 返回 Token 对象
 */
public static Oauth2AccessToken readAccessToken(Context context) {
    if (null == context) {
        return null;
    }
    
    Oauth2AccessToken token = new Oauth2AccessToken();
    SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
    token.setUid(pref.getString(KEY_UID, ""));
    token.setToken(pref.getString(KEY_ACCESS_TOKEN, ""));
    token.setRefreshToken(pref.getString(KEY_REFRESH_TOKEN, ""));
    token.setExpiresTime(pref.getLong(KEY_EXPIRES_IN, 0));
    
    return token;
}
 
Example 5
Source File: AccessTokenKeeper.java    From UPMiss with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 从 SharedPreferences 读取 Token 信息。
 *
 * @param context 应用程序上下文环境
 * @return 返回 Token 对象
 */
public static Oauth2AccessToken readAccessToken(Context context) {
    if (null == context) {
        return null;
    }

    Oauth2AccessToken token = new Oauth2AccessToken();
    SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
    token.setUid(pref.getString(KEY_UID, ""));
    token.setToken(pref.getString(KEY_ACCESS_TOKEN, ""));
    token.setRefreshToken(pref.getString(KEY_REFRESH_TOKEN, ""));
    token.setExpiresTime(pref.getLong(KEY_EXPIRES_IN, 0));

    return token;
}
 
Example 6
Source File: AccessTokenKeeper.java    From QiQuYing with Apache License 2.0 5 votes vote down vote up
/**
 * 从 SharedPreferences 读取 Token 信息。
 * 
 * @param context 应用程序上下文环境
 * 
 * @return 返回 Token 对象
 */
public static Oauth2AccessToken readAccessToken(Context context) {
    if (null == context) {
        return null;
    }
    
    Oauth2AccessToken token = new Oauth2AccessToken();
    SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
    token.setUid(pref.getString(KEY_UID, ""));
    token.setToken(pref.getString(KEY_ACCESS_TOKEN, ""));
    token.setRefreshToken(pref.getString(KEY_REFRESH_TOKEN, ""));
    token.setExpiresTime(pref.getLong(KEY_EXPIRES_IN, 0));
    
    return token;
}
 
Example 7
Source File: AccessTokenKeeper.java    From ESSocialSDK with Apache License 2.0 5 votes vote down vote up
/**
 * 从 SharedPreferences 读取 Token 信息。
 *
 * @param context 应用程序上下文环境
 * @return 返回 Token 对象
 */
public static Oauth2AccessToken readAccessToken(Context context) {
    if (null == context) {
        return null;
    }

    Oauth2AccessToken token = new Oauth2AccessToken();
    SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
    token.setUid(pref.getString(KEY_UID, ""));
    token.setToken(pref.getString(KEY_ACCESS_TOKEN, ""));
    token.setRefreshToken(pref.getString(KEY_REFRESH_TOKEN, ""));
    token.setExpiresTime(pref.getLong(KEY_EXPIRES_IN, 0));

    return token;
}
 
Example 8
Source File: WeiboSSOProxy.java    From ESSocialSDK with Apache License 2.0 5 votes vote down vote up
private static Oauth2AccessToken parseToken(SocialToken socialToken) {
    Oauth2AccessToken token = new Oauth2AccessToken();
    token.setUid(socialToken.getOpenId());
    token.setExpiresTime(socialToken.getExpiresTime());
    token.setToken(socialToken.getToken());

    return token;
}