本文整理汇总了Java中com.sina.weibo.sdk.auth.Oauth2AccessToken.parseAccessToken方法的典型用法代码示例。如果您正苦于以下问题:Java Oauth2AccessToken.parseAccessToken方法的具体用法?Java Oauth2AccessToken.parseAccessToken怎么用?Java Oauth2AccessToken.parseAccessToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sina.weibo.sdk.auth.Oauth2AccessToken
的用法示例。
在下文中一共展示了Oauth2AccessToken.parseAccessToken方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onComplete
import com.sina.weibo.sdk.auth.Oauth2AccessToken; //导入方法依赖的package包/类
@Override
public void onComplete(Bundle values) {
// 从 Bundle 中解析 Token
mAccessToken = Oauth2AccessToken.parseAccessToken(values);
if (mAccessToken.isSessionValid()) {
// 保存 Token 到 SharedPreferences
TokenKeeper.writeAccessToken(LoginActivity.this, mAccessToken);
Toast.makeText(LoginActivity.this,
"授权成功", Toast.LENGTH_SHORT).show();
new login().execute(UrlConstance.APP_URL + UrlConstance.KEY_LOGIN_INFO + "?usertoken=" + mAccessToken.getToken() + "&usertype=1");
} else {
// 以下几种情况,您会收到 Code:
// 1. 当您未在平台上注册的应用程序的包名与签名时;
// 2. 当您注册的应用程序包名与签名不正确时;
// 3. 当您在平台上注册的包名和签名与您当前测试的应用的包名和签名不匹配时。
String code = values.getString("code");
String message = "授权失败";
if (!TextUtils.isEmpty(code)) {
message = message + "\nObtained the code: " + code;
}
Toast.makeText(LoginActivity.this, message, Toast.LENGTH_LONG).show();
}
}
示例2: 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();
}
}
示例3: 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 {
}
}
示例4: onComplete
import com.sina.weibo.sdk.auth.Oauth2AccessToken; //导入方法依赖的package包/类
@Override
public void onComplete(Bundle values) {
if (values == null)
return;
mAccessToken = Oauth2AccessToken.parseAccessToken(values);
if (mAccessToken.isSessionValid()) {
if (authWrap.context == null)
return;
App.getDefault().setValue("sina_auth", true);
if (!TextUtils.isEmpty(mAccessToken.getToken())) {
App.getDefault().setValue("sina_token", mAccessToken.getToken());
}
shareListener.onComplete(ShareType, ShareConstant.SHARE_MEDIA.SINA, values);
if (listener != null) {
listener.onSuccess();
}
} else {
ShareException exception = new ShareException("授权失败");
shareListener.onException(ShareType, ShareConstant.SHARE_MEDIA.SINA, exception);
}
}
示例5: 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));
}
}
示例6: 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);
}
}
示例7: onComplete
import com.sina.weibo.sdk.auth.Oauth2AccessToken; //导入方法依赖的package包/类
@Override
public void onComplete(Bundle values) {
// 从 Bundle 中解析 Token
mAccessToken = Oauth2AccessToken.parseAccessToken(values);
//从这里获取用户输入的 电话号码信息
String phoneNum = mAccessToken.getPhoneNum();
if (mAccessToken.isSessionValid()) {
// 显示 Token
updateTokenView(false);
// 保存 Token 到 SharedPreferences
AccessTokenKeeper.writeAccessToken(WBAuthActivity.this, mAccessToken);
Toast.makeText(WBAuthActivity.this,
R.string.weibosdk_demo_toast_auth_success, Toast.LENGTH_SHORT).show();
} 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;
}
Toast.makeText(WBAuthActivity.this, message, Toast.LENGTH_LONG).show();
}
}
示例8: onComplete
import com.sina.weibo.sdk.auth.Oauth2AccessToken; //导入方法依赖的package包/类
@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();
}
示例9: 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();
}
}
}