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


Java Oauth2AccessToken.isSessionValid方法代码示例

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


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

示例1: onComplete

import com.sina.weibo.sdk.auth.Oauth2AccessToken; //导入方法依赖的package包/类
@Override
public void onComplete(Bundle values) {
    Log.i(TAG, "AuthListener.onComplete");
    Oauth2AccessToken accessToken = Oauth2AccessToken.parseAccessToken(values);
    if (accessToken != null && accessToken.isSessionValid()) {
        //UsersAPI userAPI=new UsersAPI(accessToken);
        //userAPI.show(Long.parseLong(accessToken.getUid()), userListener);

        String date = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(
                new java.util.Date(accessToken.getExpiresTime()));
        System.out.println("uid=" + accessToken.getUid());
        System.out.println("access_token=" + accessToken.getToken());
        System.out.println("expiresTime=" + date);
        AccessTokenKeeper.writeAccessToken(mContext, accessToken);
        shareToWeibo();
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:18,代码来源:BaseDialog.java

示例2: onComplete

import com.sina.weibo.sdk.auth.Oauth2AccessToken; //导入方法依赖的package包/类
@Override
public void onComplete(Bundle bundle) {
    // 从 Bundle 中解析 Token
    Oauth2AccessToken accessToken = Oauth2AccessToken.parseAccessToken(bundle);
    if (accessToken.isSessionValid()) {
        // save accessToken
        WeiboData.writeAccessToken(this, accessToken);

        // sign in succeed, show main activity
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        finish();
    } else {

    }
}
 
开发者ID:sherlockchou86,项目名称:yphoto,代码行数:17,代码来源:SignInActivity.java

示例3: onComplete

import com.sina.weibo.sdk.auth.Oauth2AccessToken; //导入方法依赖的package包/类
/**
 * 封装了 "access_token","expires_in","refresh_token",并提供了他们的管理功能
 */
@Override
public void onComplete(Bundle values) {
    LogUtils.e(TAG,"wb_auth", "complete " + values.toString());
    // 从 Bundle 中解析 Token
    Oauth2AccessToken mAccessToken = Oauth2AccessToken.parseAccessToken(values);
    //从这里获取用户输入的 电话号码信息
    //String phoneNum = mAccessToken.getPhoneNum();
    if (mAccessToken.isSessionValid()) {
        // 授权成功
        TokenStoreUtils.saveWbToken(context, mAccessToken);
        listener.onAuth(mAccessToken);
    } else {
        // 以下几种情况,您会收到 Code:
        // 1. 当您未在平台上注册的应用程序的包名与签名时;
        // 2. 当您注册的应用程序包名与签名不正确时;
        // 3. 当您在平台上注册的包名和签名与您当前测试的应用的包名和签名不匹配时。
        String code = values.getString("code");
        // 授权失败
        LogUtils.e(TAG,"wb_auth", "授权失败 " + code);
        listener.onException(new SocialException("授权失败 code = " + code));
    }
}
 
开发者ID:chendongMarch,项目名称:SocialSdkLibrary,代码行数:26,代码来源:WbAuthHelper.java

示例4: onComplete

import com.sina.weibo.sdk.auth.Oauth2AccessToken; //导入方法依赖的package包/类
@Override
public void onComplete(Bundle values) {
    final Oauth2AccessToken accessToken = Oauth2AccessToken.parseAccessToken(values);
    if (accessToken != null && accessToken.isSessionValid()) {
        AccessTokenKeeper.writeAccessToken(mContext, accessToken);
        userAPI = new UsersAPI(mContext, mSinaAppKey, accessToken);
        userAPI.show(Long.parseLong(accessToken.getUid()), mListener);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:WeiboLoginManager.java

示例5: onClick

import com.sina.weibo.sdk.auth.Oauth2AccessToken; //导入方法依赖的package包/类
/**
 * 点击邀请按钮时,该函数被调用 。
 */
@Override
public void onClick(View v) {
    
    // 创建请求的 JSON 数据对象
    JSONObject jsonObject = new JSONObject();
    try {
        jsonObject.put(InviteAPI.KEY_TEXT,        "这个游戏太好玩了,加入一起玩吧");
        jsonObject.put(InviteAPI.KEY_URL,         "http://app.sina.com.cn/appdetail.php?appID=770915");
        jsonObject.put(InviteAPI.KEY_INVITE_LOGO, "http://hubimage.com2us.com/hubweb/contents/123_499.jpg");
    } catch (JSONException e) {
        e.printStackTrace();
    }
    
    // 获取被邀请人的 Uid
    String uid = mEditText.getText().toString();
    //String uid = "2785593564";
    
    // 获取 Token
    Oauth2AccessToken accessToken = AccessTokenKeeper.readAccessToken(WBInviteAPIActivity.this);
    if (accessToken != null && accessToken.isSessionValid()) {
        // 调用 OpenAPI 接口发送邀请
        new InviteAPI(this, Constants.APP_KEY, accessToken).sendInvite(uid, jsonObject, mInviteRequestListener);
    } else {
        Toast.makeText(WBInviteAPIActivity.this, R.string.weibosdk_demo_access_token_is_empty, Toast.LENGTH_LONG).show();
    }
}
 
开发者ID:ligongzai,项目名称:QianXun,代码行数:30,代码来源:WBInviteAPIActivity.java

示例6: isSignedIn

import com.sina.weibo.sdk.auth.Oauth2AccessToken; //导入方法依赖的package包/类
private boolean isSignedIn() {
    Oauth2AccessToken token = WeiboData.readAccessToken(this);
    if (token != null && token.isSessionValid()) {
        return true;
    }
    return false;
}
 
开发者ID:sherlockchou86,项目名称:yphoto,代码行数:8,代码来源:SignInActivity.java

示例7: auth

import com.sina.weibo.sdk.auth.Oauth2AccessToken; //导入方法依赖的package包/类
public static void auth(Activity activity, SsoHandler mSsoHandler, OnAuthOverListener listener) {
        Oauth2AccessToken token = TokenStoreUtils.getWbToken(activity);
        if (token != null && token.isSessionValid()) {
            listener.onAuth(token);
        } else {
            // 创建微博实例
            // 快速授权时,请不要传入 SCOPE,否则可能会授权不成功
            LogUtils.e(TAG, "wb_auth", "开始授权");
            mSsoHandler.authorize(new MyWeiboAuthListener(activity, listener));
//            mSsoHandler.authorizeClientSso(new MyWeiboAuthListener(activity,listener));
        }
    }
 
开发者ID:chendongMarch,项目名称:SocialSdkLibrary,代码行数:13,代码来源:WbAuthHelper.java

示例8: authorizeCallBack

import com.sina.weibo.sdk.auth.Oauth2AccessToken; //导入方法依赖的package包/类
public void authorizeCallBack(int requestCode, int resultCode, Intent data) {
    LogUtil.d(TAG, "requestCode: " + requestCode + ", resultCode: " + resultCode + ", data: " + data);
    String error;
    Bundle bundle;
    Oauth2AccessToken accessToken;
    if (requestCode == this.mSSOAuthRequestCode) {
        if (resultCode == -1) {
            if (SecurityHelper.checkResponseAppLegal(this.mAuthActivity, this.mWeiboInfo, data)) {
                error = data.getStringExtra(NativeProtocol.BRIDGE_ARG_ERROR_BUNDLE);
                if (error == null) {
                    error = data.getStringExtra(NativeProtocol.BRIDGE_ARG_ERROR_TYPE);
                }
                if (error == null) {
                    bundle = data.getExtras();
                    accessToken = Oauth2AccessToken.parseAccessToken(bundle);
                    if (accessToken == null || !accessToken.isSessionValid()) {
                        LogUtil.d(TAG, "Failed to receive access token by SSO");
                        this.mWebAuthHandler.anthorize(this.mAuthListener);
                        return;
                    }
                    LogUtil.d(TAG, "Login Success! " + accessToken.toString());
                    this.mAuthListener.onComplete(bundle);
                } else if (error.equals("access_denied") || error.equals("OAuthAccessDeniedException")) {
                    LogUtil.d(TAG, "Login canceled by user.");
                    this.mAuthListener.onCancel();
                } else {
                    String description = data.getStringExtra(NativeProtocol.BRIDGE_ARG_ERROR_DESCRIPTION);
                    if (description != null) {
                        error = new StringBuilder(String.valueOf(error)).append(NetworkUtils.DELIMITER_COLON).append(description).toString();
                    }
                    LogUtil.d(TAG, "Login failed: " + error);
                    this.mAuthListener.onWeiboException(new WeiboDialogException(error, resultCode, description));
                }
            }
        } else if (resultCode != 0) {
        } else {
            if (data != null) {
                LogUtil.d(TAG, "Login failed: " + data.getStringExtra(NativeProtocol.BRIDGE_ARG_ERROR_BUNDLE));
                this.mAuthListener.onWeiboException(new WeiboDialogException(data.getStringExtra(NativeProtocol.BRIDGE_ARG_ERROR_BUNDLE), data.getIntExtra(NativeProtocol.BRIDGE_ARG_ERROR_CODE, -1), data.getStringExtra("failing_url")));
                return;
            }
            LogUtil.d(TAG, "Login canceled by user.");
            this.mAuthListener.onCancel();
        }
    } else if (requestCode != REQUEST_CODE_MOBILE_REGISTER) {
    } else {
        if (resultCode == -1) {
            bundle = data.getExtras();
            accessToken = Oauth2AccessToken.parseAccessToken(bundle);
            if (accessToken != null && accessToken.isSessionValid()) {
                LogUtil.d(TAG, "Login Success! " + accessToken.toString());
                this.mAuthListener.onComplete(bundle);
            }
        } else if (resultCode != 0) {
        } else {
            if (data != null) {
                LogUtil.d(TAG, "Login failed: " + data.getStringExtra(NativeProtocol.BRIDGE_ARG_ERROR_BUNDLE));
                error = data.getStringExtra(NativeProtocol.BRIDGE_ARG_ERROR_BUNDLE);
                if (error == null) {
                    error = data.getStringExtra(NativeProtocol.BRIDGE_ARG_ERROR_TYPE);
                }
                if (error != null) {
                    this.mAuthListener.onWeiboException(new WeiboDialogException(data.getStringExtra(NativeProtocol.BRIDGE_ARG_ERROR_BUNDLE), data.getIntExtra(NativeProtocol.BRIDGE_ARG_ERROR_CODE, -1), data.getStringExtra(NativeProtocol.BRIDGE_ARG_ERROR_DESCRIPTION)));
                    return;
                }
                return;
            }
            LogUtil.d(TAG, "Login canceled by user.");
            this.mAuthListener.onCancel();
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:73,代码来源:SsoHandler.java


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