com.sina.weibo.sdk.auth.Oauth2AccessToken Java Examples
The following examples show how to use
com.sina.weibo.sdk.auth.Oauth2AccessToken.
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: Login.java From LoginSharePay with Apache License 2.0 | 6 votes |
@Override public void onSuccess(Oauth2AccessToken oauth2AccessToken) { if (oauth2AccessToken.isSessionValid()) { Map<String, String> body = new HashMap<>(); body.put("uid", oauth2AccessToken.getUid()); body.put("access_token", oauth2AccessToken.getToken()); new LoginShareHttp(Config.WEIBO_USERINFO_URL, body) { @Override public void onResult(int code, String result) { if (listener == null) { return; } if (code == 0) { listener.onLoginSuccess(Type.Weibo, result); } else { listener.onLoginError(Type.Weibo, code); } } }; } }
Example #2
Source File: SinaShareHandler.java From BiliShare with Apache License 2.0 | 6 votes |
@Override public void onSuccess(Oauth2AccessToken oauth2AccessToken) { Log.d(TAG, "auth success"); mSsoHandler = null; if (oauth2AccessToken.isSessionValid()) { AccessTokenKeeper.writeAccessToken(getContext(), oauth2AccessToken); if (mWeiboMessage != null) { allInOneShare(mWeiboMessage); } return; } SocializeListeners.ShareListener listener = getShareListener(); if (listener == null) { return; } listener.onError(SocializeMedia.SINA, BiliShareStatusCode.ST_CODE_SHARE_ERROR_AUTH_FAILED, new ShareException("无效的token")); }
Example #3
Source File: WbShareHandler.java From LoginSharePay with Apache License 2.0 | 6 votes |
private void startWebShare(WeiboMultiMessage message) { Intent webIntent = new Intent(this.context, WbShareTransActivity.class); String appPackage = this.context.getPackageName(); ShareWebViewRequestParam webParam = new ShareWebViewRequestParam(WbSdk.getAuthInfo(), WebRequestType.SHARE, "", 1, "微博分享", (String)null, this.context); webParam.setContext(this.context); webParam.setHashKey(""); webParam.setPackageName(appPackage); Oauth2AccessToken token = AccessTokenKeeper.readAccessToken(this.context); if(token != null && !TextUtils.isEmpty(token.getToken())) { webParam.setToken(token.getToken()); } webParam.setMultiMessage(message); Bundle bundle = new Bundle(); webParam.fillBundle(bundle); webIntent.putExtras(bundle); webIntent.putExtra("startFlag", 0); webIntent.putExtra("startActivity", this.context.getClass().getName()); webIntent.putExtra("startAction", "com.sina.weibo.sdk.action.ACTION_WEIBO_ACTIVITY"); webIntent.putExtra("gotoActivity", "com.sina.weibo.sdk.web.WeiboSdkWebActivity"); this.context.startActivity(webIntent); }
Example #4
Source File: BaseDialog.java From AssistantBySDK with Apache License 2.0 | 6 votes |
@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(); } }
Example #5
Source File: WBHelper.java From SocialHelper with Apache License 2.0 | 6 votes |
/** * 3、获取用户信息 */ private void getUserInfo(final Oauth2AccessToken accessToken) { new Thread(new Runnable() { @Override public void run() { try { if (accessToken == null) { handler.sendEmptyMessage(GET_INFO_ERROR); return; } URL url = new URL("https://api.weibo.com/2/users/show.json?access_token=" + accessToken.getToken() + "&uid=" + accessToken.getUid() + ""); wbInfo = new Gson().fromJson(SocialUtil.get(url), WBInfoEntity.class); if (isNeedLoginResult()) { wbInfo.setLoginResultEntity(loginResult); } handler.sendEmptyMessage(GET_INFO_SUCCESS); } catch (Exception e) { e.printStackTrace(); handler.sendEmptyMessage(GET_INFO_ERROR); } } }).start(); }
Example #6
Source File: WbLoginHelper.java From SocialSdkLibrary with Apache License 2.0 | 6 votes |
public void login(Activity activity, final OnLoginStateListener listener) { if (listener == null) return; mOnLoginListener = listener; justAuth(activity, new WbAuthListener() { @Override public void onSuccess(Oauth2AccessToken oauth2AccessToken) { getUserInfo(oauth2AccessToken); } @Override public void cancel() { listener.onState(null, LoginResult.cancelOf()); } @Override public void onFailure(WbConnectErrorMessage msg) { listener.onState(null, LoginResult.failOf(SocialError.make(SocialError.CODE_SDK_ERROR, TAG + "#login#connect error," + msg.getErrorCode() + " " + msg.getErrorMessage()))); } }); }
Example #7
Source File: LoginoutButton.java From AssistantBySDK with Apache License 2.0 | 5 votes |
/** * 设置注销时,需要设置的 Token 信息以及注销后的回调接口。 * * @param accessToken AccessToken 信息 * @param logoutListener 注销回调 */ public void setLogoutInfo(Oauth2AccessToken accessToken, RequestListener logoutListener) { mAccessToken = accessToken; mLogoutListener = logoutListener; if (mAccessToken != null && mAccessToken.isSessionValid()) { setText(R.string.com_sina_weibo_sdk_logout); } }
Example #8
Source File: AccessTokenKeeper.java From AssistantBySDK with Apache License 2.0 | 5 votes |
/** * 保存 Token 对象到 SharedPreferences。 * * @param context 应用程序上下文环境 * @param token Token 对象 */ public static void writeAccessToken(Context context, Oauth2AccessToken token) { if (null == context || null == token) { return; } SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND); Editor editor = pref.edit(); editor.putString(KEY_UID, token.getUid()); editor.putString(KEY_ACCESS_TOKEN, token.getToken()); editor.putLong(KEY_EXPIRES_IN, token.getExpiresTime()); editor.commit(); }
Example #9
Source File: WeiboShareProxy.java From ESSocialSDK with Apache License 2.0 | 5 votes |
private static void shareTo(final Context context, final String appKey, final String redirectUrl, final String scop, final String title, final String desc, final String imageUrl, final String shareUrl, final WeiboAuthListener listener) { new Thread(new Runnable() { @Override public void run() { WeiboMultiMessage msg = new WeiboMultiMessage(); TextObject text = new TextObject(); text.text = desc; msg.textObject = text; WebpageObject web = new WebpageObject(); web.description = desc; byte[] thumb = SocialUtils.getHtmlByteArray(imageUrl); if (null != thumb) web.thumbData = SocialUtils.compressBitmap(thumb, 32); else web.thumbData = SocialUtils.compressBitmap(SocialUtils.getDefaultShareImage(context), 32); web.actionUrl = shareUrl; web.identify = imageUrl; web.title = title; msg.mediaObject = web; SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest(); request.transaction = String.valueOf(System.currentTimeMillis()); request.multiMessage = msg; AuthInfo authInfo = new AuthInfo(context, appKey, redirectUrl, scop); Oauth2AccessToken accessToken = AccessTokenKeeper.readAccessToken(context); String token = ""; if (accessToken != null) { token = accessToken.getToken(); } getInstance(context, appKey).sendRequest((Activity) context, request, authInfo, token, listener); } }).start(); }
Example #10
Source File: SinaShareHandler.java From BiliShare with Apache License 2.0 | 5 votes |
private String getToken() { Oauth2AccessToken mAccessToken = AccessTokenKeeper.readAccessToken(getContext()); String token = null; if (mAccessToken != null) { token = mAccessToken.getToken(); } return token; }
Example #11
Source File: AccessTokenKeeper.java From UPMiss with GNU General Public License v3.0 | 5 votes |
/** * 保存 Token 对象到 SharedPreferences。 * * @param context 应用程序上下文环境 * @param token Token 对象 */ public static void writeAccessToken(Context context, Oauth2AccessToken token) { if (null == context || null == token) { return; } SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND); SharedPreferences.Editor editor = pref.edit(); editor.putString(KEY_UID, token.getUid()); editor.putString(KEY_ACCESS_TOKEN, token.getToken()); editor.putString(KEY_REFRESH_TOKEN, token.getRefreshToken()); editor.putLong(KEY_EXPIRES_IN, token.getExpiresTime()); editor.apply(); }
Example #12
Source File: AccessTokenKeeper.java From BiliShare with Apache License 2.0 | 5 votes |
/** * 保存 Token 对象到 SharedPreferences。 * * @param context 应用程序上下文环境 * @param token Token 对象 */ public static void writeAccessToken(Context context, Oauth2AccessToken token) { if (null == context || null == token) { return; } SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND); Editor editor = pref.edit(); editor.putString(KEY_UID, token.getUid()); editor.putString(KEY_ACCESS_TOKEN, token.getToken()); editor.putString(KEY_REFRESH_TOKEN, token.getRefreshToken()); editor.putLong(KEY_EXPIRES_IN, token.getExpiresTime()); editor.commit(); }
Example #13
Source File: AccessTokenKeeper.java From BiliShare with Apache License 2.0 | 5 votes |
/** * 从 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 #14
Source File: AccessTokenKeeper.java From AssistantBySDK with Apache License 2.0 | 5 votes |
/** * 从 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 #15
Source File: AccessTokenKeeper.java From ChinaShare with MIT License | 5 votes |
/** * 保存 Token 对象到 SharedPreferences。 * * @param context 应用程序上下文环境 * @param token Token 对象 */ public static void writeAccessToken(Context context, Oauth2AccessToken token) { if (null == context || null == token) { return; } SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND); Editor editor = pref.edit(); editor.putString(KEY_UID, token.getUid()); editor.putString(KEY_ACCESS_TOKEN, token.getToken()); editor.putString(KEY_REFRESH_TOKEN, token.getRefreshToken()); editor.putLong(KEY_EXPIRES_IN, token.getExpiresTime()); editor.commit(); }
Example #16
Source File: AccessTokenKeeper.java From ESSocialSDK with Apache License 2.0 | 5 votes |
/** * 从 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 #17
Source File: WeiboToken.java From ShareUtil with Apache License 2.0 | 5 votes |
public static WeiboToken parse(Oauth2AccessToken token) { WeiboToken target = new WeiboToken(); target.setOpenid(token.getUid()); target.setAccessToken(token.getToken()); target.setRefreshToken(token.getRefreshToken()); target.setPhoneNum(token.getPhoneNum()); return target; }
Example #18
Source File: WeiboToken.java From ShareLoginPayUtil with Apache License 2.0 | 5 votes |
public WeiboToken(Oauth2AccessToken token) { if (token == null) { return; } setOpenid(token.getUid()); setAccessToken(token.getToken()); setRefreshToken(token.getRefreshToken()); setPhoneNum(token.getPhoneNum()); }
Example #19
Source File: Utility.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
public static Bundle formBundle(Oauth2AccessToken oauth2accesstoken) { Bundle bundle = new Bundle(); bundle.putString("access_token", oauth2accesstoken.getToken()); bundle.putString("refresh_token", oauth2accesstoken.getRefreshToken()); bundle.putString("expires_in", (new StringBuilder(String.valueOf(oauth2accesstoken.getExpiresTime()))).toString()); return bundle; }
Example #20
Source File: AuthPresenter.java From the-tech-frontier-app with MIT License | 5 votes |
@Override public void onComplete(Bundle values) { mAccessToken = Oauth2AccessToken.parseAccessToken(values); if (mAccessToken.isSessionValid()) { final String uid = mAccessToken.getUid(); final String token = mAccessToken.getToken(); Log.i("RESULT", mAccessToken.toString()); mUserAPI.fetchUserInfo(uid, token, new DataListener<UserInfo>() { @Override public void onComplete(UserInfo result) { result.token = token; result.uid = uid; LoginSession.getLoginSession().saveUserInfo(result); if (mDataListener != null) { mDataListener.onComplete(result); } } }); } else { // 以下几种情况,您会收到 Code: // 1. 当您未在平台上注册的应用程序的包名与签名时; // 2. 当您注册的应用程序包名与签名不正确时; // 3. 当您在平台上注册的包名和签名与您当前测试的应用的包名和签名不匹配时。 // String code = values.getString("code"); } }
Example #21
Source File: BaseHandler.java From LoginSharePay with Apache License 2.0 | 5 votes |
public void authorizeCallBack(int requestCode, int resultCode, Intent data) { if ('胍' == requestCode) { if (resultCode == -1) { if (!SecurityHelper.checkResponseAppLegal(this.mAuthFragment.getContext(), WeiboAppManager.getInstance(this.mAuthFragment.getContext()).getWbAppInfo(), data)) { this.authListener.onFailure(new WbConnectErrorMessage("your install weibo app is counterfeit", "8001")); return; } String error = Utility.safeString(data.getStringExtra("error")); String error_type = Utility.safeString(data.getStringExtra("error_type")); String error_description = Utility.safeString(data.getStringExtra("error_description")); LogUtil.d("WBAgent", "error: " + error + ", error_type: " + error_type + ", error_description: " + error_description); if (TextUtils.isEmpty(error) && TextUtils.isEmpty(error_type) && TextUtils.isEmpty(error_description)) { Bundle bundle = data.getExtras(); Oauth2AccessToken accessToken = Oauth2AccessToken.parseAccessToken(bundle); if (accessToken != null && accessToken.isSessionValid()) { LogUtil.d("WBAgent", "Login Success! " + accessToken.toString()); AccessTokenKeeper.writeAccessToken(this.mAuthFragment.getContext(), accessToken); this.authListener.onSuccess(accessToken); } } else if (!"access_denied".equals(error) && !"OAuthAccessDeniedException".equals(error)) { LogUtil.d("WBAgent", "Login failed: " + error); this.authListener.onFailure(new WbConnectErrorMessage(error_type, error_description)); } else { LogUtil.d("WBAgent", "Login canceled by user."); this.authListener.cancel(); } } else if (resultCode == 0) { if (data != null) { this.authListener.cancel(); } else { this.authListener.cancel(); } } } }
Example #22
Source File: SocialShareProxy.java From ESSocialSDK with Apache License 2.0 | 5 votes |
/** * 分享到微博 * * @param context context * @param appKey app key * @param redirectUrl 回调地址 * @param scene 场景 */ public static void shareToWeibo(final Context context, String appKey, String redirectUrl, final SocialShareScene scene) { if (DEBUG) Log.i(TAG, "SocialShareProxy#shareToWeibo"); WeiboShareProxy.shareTo(context, appKey, redirectUrl, scene.getTitle(), scene.getDesc(), scene.getThumbnail(), scene.getUrl(), new WeiboAuthListener() { @Override public void onComplete(Bundle bundle) { if (DEBUG) Log.i(TAG, "SocialShareProxy#shareToWeibo onComplete"); Oauth2AccessToken token = Oauth2AccessToken.parseAccessToken(bundle); if (token.isSessionValid()) AccessTokenKeeper.writeAccessToken(context, token); // BusProvider.getInstance().post(new ShareBusEvent(ShareBusEvent.TYPE_SUCCESS, scene.getType(), scene.getId())); } @Override public void onWeiboException(WeiboException e) { if (DEBUG) Log.i(TAG, "SocialShareProxy#shareToWeibo onWeiboException " + e.toString()); // BusProvider.getInstance().post(new ShareBusEvent(ShareBusEvent.TYPE_FAILURE, scene.getType(), e)); } @Override public void onCancel() { if (DEBUG) Log.i(TAG, "SocialShareProxy#shareToWeibo onCancel"); // BusProvider.getInstance().post(new ShareBusEvent(ShareBusEvent.TYPE_CANCEL, scene.getType())); } }); }
Example #23
Source File: AccessTokenKeeper.java From QiQuYing with Apache License 2.0 | 5 votes |
/** * 保存 Token 对象到 SharedPreferences。 * * @param context 应用程序上下文环境 * @param token Token 对象 */ public static void writeAccessToken(Context context, Oauth2AccessToken token) { if (null == context || null == token) { return; } SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND); Editor editor = pref.edit(); editor.putString(KEY_UID, token.getUid()); editor.putString(KEY_ACCESS_TOKEN, token.getToken()); editor.putString(KEY_REFRESH_TOKEN, token.getRefreshToken()); editor.putLong(KEY_EXPIRES_IN, token.getExpiresTime()); editor.commit(); }
Example #24
Source File: WbLoginHelper.java From SocialSdkLibrary with Apache License 2.0 | 5 votes |
public void justAuth(final Activity activity, final WbAuthListener listener) { Oauth2AccessToken token = AccessToken.getToken(activity, mLoginTarget, Oauth2AccessToken.class); if (token != null && token.isSessionValid() && token.getExpiresTime() > System.currentTimeMillis()) { listener.onSuccess(token); } else { AccessToken.clearToken(activity, Target.LOGIN_WB); mSsoHandler.authorize(new WbAuthListener() { @Override public void onSuccess(Oauth2AccessToken oauth2AccessToken) { oauth2AccessToken.setBundle(null); SocialUtil.json("test", oauth2AccessToken.toString()); AccessToken.saveToken(activity, mLoginTarget, oauth2AccessToken); listener.onSuccess(oauth2AccessToken); } @Override public void cancel() { listener.cancel(); } @Override public void onFailure(WbConnectErrorMessage wbConnectErrorMessage) { listener.onFailure(wbConnectErrorMessage); } }); } }
Example #25
Source File: OpenApiShareHelper.java From SocialSdkLibrary with Apache License 2.0 | 5 votes |
void post(Activity activity, final ShareObj obj) { mWbLoginHelper.justAuth(activity, new WbAuthListenerImpl() { @Override public void onSuccess(final Oauth2AccessToken token) { Task.callInBackground(() -> { Map<String, String> params = new HashMap<>(); params.put("access_token", token.getToken()); params.put("status", obj.getSummary()); return _SocialSdk.getInst().getRequestAdapter().postData("https://api.weibo.com/2/statuses/share.json", params, "pic", obj.getThumbImagePath()); }).continueWith(task -> { if (task.isFaulted() || TextUtils.isEmpty(task.getResult())) { throw SocialError.make(SocialError.CODE_PARSE_ERROR, "open api 分享失败 " + task.getResult(), task.getError()); } else { JSONObject jsonObject = new JSONObject(task.getResult()); if (jsonObject.has("id") && jsonObject.get("id") != null) { mPlatform.onShareSuccess(); return true; } else { throw SocialError.make(SocialError.CODE_PARSE_ERROR, "open api 分享失败 " + task.getResult()); } } }, Task.UI_THREAD_EXECUTOR).continueWith(task -> { if (task != null && task.isFaulted()) { Exception error = task.getError(); if (error instanceof SocialError) { mPlatform.onShareFail((SocialError) error); } else { mPlatform.onShareFail(SocialError.make(SocialError.CODE_REQUEST_ERROR, "open api 分享失败", error)); } } return true; }, Task.UI_THREAD_EXECUTOR); } }); }
Example #26
Source File: SharePopWindow.java From QiQuYing with Apache License 2.0 | 5 votes |
/** * 分享到新浪微博 */ private void share2SinaWeibo() { Oauth2AccessToken accessToken = AccessTokenKeeper.readAccessToken(context); if(accessToken != null && accessToken.isSessionValid()) { initShareWeiboAPI(); share2weibo(); } else { //需要授权登录 initSinaWeiBo(); initShareWeiboAPI(); mSsoHandler.authorize(new AuthListener()); //授权后再分享 } }
Example #27
Source File: SinaAccessToken.java From SocialSdkLibrary with Apache License 2.0 | 5 votes |
public SinaAccessToken(Oauth2AccessToken token) { this.setOpenid(token.getUid()); this.setAccess_token(token.getToken()); this.setExpires_in(token.getExpiresTime()); this.refresh_token = token.getRefreshToken(); this.phone = token.getPhoneNum(); }
Example #28
Source File: UserServices.java From Simpler with Apache License 2.0 | 5 votes |
/** * 更新Oauth2AccessToken * * @param uid 用户Id * @param token Oauth2AccessToken */ public void updateOauth2AccessToken(String uid, Oauth2AccessToken token) { SQLiteDatabase db = this.dbHelper.getReadableDatabase(); String sql = "UPDATE " + DBInfo.Table.USER_TB_NAME + " SET " + Account.ACCESS_TOKEN + "='" + token.getToken() + "', " + Account.EXPIRES_IN + "=" + token.getExpiresTime() + ", " + Account.REFRESH_TOKEN + "='" + token.getRefreshToken() + "' WHERE " + Account.UID + "='" + uid + "'"; db.execSQL(sql); db.close(); }
Example #29
Source File: WBLoginActivity.java From Simpler with Apache License 2.0 | 5 votes |
@Override public void onComplete(Bundle values) { // 从 Bundle 中解析 Token mAccessToken = Oauth2AccessToken.parseAccessToken(values); //从这里获取用户输入的 电话号码信息 String phoneNum = mAccessToken.getPhoneNum(); if (mAccessToken.isSessionValid()) { // Log.d("Auth", sAccessToken.toString()); // 保存 Token AccessTokenKeeper.writeAccessToken(mAccessToken); AppToast.showToast(R.string.weibosdk_demo_toast_auth_success, Toast.LENGTH_SHORT); BaseConfig.sTokenExpired = false; if (BaseConfig.sAddAccountMode) { // 添加帐号模式,结束之前所有Activity App.getInstance().finishAllActivities(); } startActivity(MainActivity.newIntent(WBLoginActivity.this)); } else { // 以下几种情况,您会收到 Code: // 1. 当您未在平台上注册的应用程序的包名与签名时; // 2. 当您注册的应用程序包名与签名不正确时; // 3. 当您在平台上注册的包名和签名与您当前测试的应用的包名和签名不匹配时。 String code = values.getString("code"); String message = getString(R.string.weibosdk_demo_toast_auth_failed); if (!TextUtils.isEmpty(code)) { message = message + "\nObtained the code: " + code; } AppToast.showToast(message, Toast.LENGTH_LONG); } finish(); }
Example #30
Source File: AccountUtil.java From Simpler with Apache License 2.0 | 5 votes |
/** * 更新Oauth2AccessToken * * @param token */ public static void updateOauth2AccessToken(Oauth2AccessToken token) { BaseConfig.sAccessToken = token; if (App.userServices.getAccountById(BaseConfig.sUid) == null) { // 同步到数据库 Account account = new Account(BaseConfig.sUid, token.getToken(), token.getExpiresTime(), token.getRefreshToken()); App.userServices.insertAccount(account); } else { // 同步到数据库 App.userServices.updateOauth2AccessToken(BaseConfig.sUid, token); } }