com.sina.weibo.sdk.auth.WbConnectErrorMessage Java Examples

The following examples show how to use com.sina.weibo.sdk.auth.WbConnectErrorMessage. 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: WbLoginHelper.java    From SocialSdkLibrary with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: WeiboLoginInstance.java    From ShareLoginPayUtil with Apache License 2.0 5 votes vote down vote up
@Override
public void onFailure(WbConnectErrorMessage errorMessage) {
    if (mLoginListener != null) {
        mLoginListener.loginFailure(new Exception(errorMessage.getErrorMessage()), ShareLogger.INFO.ERR_AUTH_CODE);
        LoginUtil.recycle();
    }
}
 
Example #3
Source File: BaseHandler.java    From LoginSharePay with Apache License 2.0 5 votes vote down vote up
private void authorize(int requestCode, WbAuthListener listener, BaseHandler.AuthType authType) {
    this.resetIntentFillData();
    if (listener == null) {
        throw new RuntimeException("please set auth listener");
    } else {
        this.authListener = listener;
        if (authType == BaseHandler.AuthType.WebOnly) {
            if (listener != null) {
                this.startWebAuth();
            }

        } else {
            boolean onlyClientSso = false;
            if (authType == BaseHandler.AuthType.SsoOnly) {
                onlyClientSso = true;
            }

            if (this.isWbAppInstalled()) {
                this.startClientAuth(requestCode);
            } else if (onlyClientSso) {
                this.authListener.onFailure(new WbConnectErrorMessage());
            } else {
                this.startWebAuth();
            }

        }
    }
}
 
Example #4
Source File: BaseHandler.java    From LoginSharePay with Apache License 2.0 5 votes vote down vote up
protected void startClientAuth(int requestCode) {
    try {
        WbAppInfo wbAppInfo = WeiboAppManager.getInstance(this.mAuthFragment.getContext()).getWbAppInfo();
        Intent intent = new Intent();
        intent.setClassName(wbAppInfo.getPackageName(), wbAppInfo.getAuthActivityName());
        intent.putExtras(WbSdk.getAuthInfo().getAuthBundle());
        intent.putExtra("_weibo_command_type", 3);
        intent.putExtra("_weibo_transaction", String.valueOf(System.currentTimeMillis()));
        intent.putExtra("aid", Utility.getAid(this.mAuthFragment.getContext(), WbSdk.getAuthInfo().getAppKey()));
        if (!SecurityHelper.validateAppSignatureForIntent(this.mAuthFragment.getContext(), intent)) {
            return;
        }

        this.fillExtraIntent(intent, requestCode);

        try {
            this.mAuthFragment.startActivityForResult(intent, this.ssoRequestCode);
        } catch (Exception var5) {
            if (this.authListener != null) {
                this.authListener.onFailure(new WbConnectErrorMessage());
            }

            this.couldNotStartWbSsoActivity();
        }
    } catch (Exception var6) {
        ;
    }

}
 
Example #5
Source File: BaseHandler.java    From LoginSharePay with Apache License 2.0 5 votes vote down vote up
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 #6
Source File: WBHelper.java    From SocialHelper with Apache License 2.0 5 votes vote down vote up
private void initLoginListener() {
    wbAuthCallback = new WbAuthListener() {
        @Override
        public void onSuccess(Oauth2AccessToken oauth2AccessToken) {
            if (oauth2AccessToken.isSessionValid()) {
                loginResult = oauth2AccessToken;
                AccessTokenKeeper.writeAccessToken(activity, oauth2AccessToken);
                getUserInfo(oauth2AccessToken);
            } else {
                handler.sendEmptyMessage(GET_INFO_ERROR);
            }
        }

        @Override
        public void cancel() {
            if (loginCallback != null && activity != null) {
                loginCallback.socialError(activity.getString(R.string.social_cancel));
            }
        }

        @Override
        public void onFailure(WbConnectErrorMessage error) {
            if (loginCallback != null) {
                loginCallback.socialError(error.getErrorMessage());
            }
        }
    };
}
 
Example #7
Source File: WbLoginHelper.java    From SocialSdkLibrary with Apache License 2.0 5 votes vote down vote up
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 #8
Source File: SinaShareHandler.java    From BiliShare with Apache License 2.0 5 votes vote down vote up
@Override
public void onFailure(WbConnectErrorMessage wbConnectErrorMessage) {
    Log.d(TAG, "auth failure");
    if (getShareListener() != null) {
        getShareListener().onError(SocializeMedia.SINA, BiliShareStatusCode.ST_CODE_SHARE_ERROR_AUTH_FAILED,
                new Exception(wbConnectErrorMessage.getErrorMessage()));
    }
    mSsoHandler = null;
}
 
Example #9
Source File: WeiboBaseShareInstance.java    From SimpleProject with MIT License 4 votes vote down vote up
@Override
public void onFailure(WbConnectErrorMessage wbConnectErrorMessage) {
	LogUtil.i("微博授权失败" + wbConnectErrorMessage.getErrorCode());
	activity.finish();
}
 
Example #10
Source File: BaseLoginListener.java    From SimpleProject with MIT License 4 votes vote down vote up
@Override
public final void onFailure(WbConnectErrorMessage wbConnectErrorMessage) {
	loginFailed(new Exception(wbConnectErrorMessage.getErrorMessage()));
}
 
Example #11
Source File: Login.java    From LoginSharePay with Apache License 2.0 4 votes vote down vote up
@Override
public void onFailure(WbConnectErrorMessage wbConnectErrorMessage) {
    if (listener != null)
        listener.onLoginError(Type.Weibo, Integer.parseInt(wbConnectErrorMessage.getErrorCode()));
}
 
Example #12
Source File: OpenApiShareHelper.java    From SocialSdkLibrary with Apache License 2.0 4 votes vote down vote up
@Override
public void onFailure(WbConnectErrorMessage msg) {
    mPlatform.onShareFail(SocialError.make(SocialError.CODE_SDK_ERROR, TAG + "#WbAuthListenerImpl#wb auth fail," + msg.getErrorCode() + " " + msg.getErrorMessage()));
}
 
Example #13
Source File: WeiboAuthManager.java    From sharesdk with Apache License 2.0 4 votes vote down vote up
@Override
public void onFailure(WbConnectErrorMessage wbConnectErrorMessage) {
    if (mAuthListener != null) {
        mAuthListener.onError(new RuntimeException(String.format(Locale.getDefault(), "error_code:%d,error_msg:%s", wbConnectErrorMessage.getErrorCode(), wbConnectErrorMessage.getErrorMessage())));
    }
}