我正在玩Quickblox q-municate并且在1:1的视频聊天中成功了一天,但现在我得到了#34; Token Required。"
我知道我需要创建一个会话,这是我提出并放在QBAuthHelper.java文件中的代码:
public class QBAuthHelper extends BaseHelper {
public QBAuthHelper(Context context) {
super(context);
}
public QBUser login(QBUser inputUser) throws QBResponseException, BaseServiceException {
QBUser user;
QBAuth.createSession();
String password = inputUser.getPassword();
user = QBUsers.signIn(inputUser);
String token = QBAuth.getBaseService().getToken();
user.setPassword(password);
AppSession.startSession(LoginType.EMAIL, user, token);
return user;
}
public QBUser login(String socialProvider, String accessToken,
String accessTokenSecret) throws QBResponseException, BaseServiceException {
QBUser user;
QBSession session = QBAuth.createSession();
user = QBUsers.signInUsingSocialProvider(socialProvider, accessToken, accessTokenSecret);
user.setPassword(session.getToken());
String token = QBAuth.getBaseService().getToken();
AppSession.startSession(LoginType.FACEBOOK, user, token);
return user;
}
public QBUser signup(QBUser inputUser, File file) throws QBResponseException, BaseServiceException {
QBUser user;
QBAuth.createSession();
String password = inputUser.getPassword();
inputUser.setOldPassword(password);
user = QBUsers.signUpSignInTask(inputUser);
if (null != file) {
QBFile qbFile = QBContent.uploadFileTask(file, true, (String) null);
user.setWebsite(qbFile.getPublicUrl());
user = QBUsers.updateUser(inputUser);
}
user.setPassword(password);
String token = QBAuth.getBaseService().getToken();
AppSession.startSession(LoginType.EMAIL, user, token);
return inputUser;
}
public void logout() throws QBResponseException {
AppSession activeSession = AppSession.getSession();
if (activeSession != null) {
activeSession.closeAndClear();
}
Session.getActiveSession().closeAndClearTokenInformation();
QBAuth.deleteSession();
}
public QBUser updateUser(QBUser inputUser) throws QBResponseException {
QBUser user;
if (!TextUtils.isEmpty(inputUser.getFacebookId()) && TextUtils.isEmpty(inputUser.getWebsite())) {
return inputUser;
}
String password = inputUser.getPassword();
user = QBUsers.updateUser(inputUser);
user.setPassword(password);
return user;
}
public QBUser updateUser(QBUser user, File file) throws QBResponseException {
QBFile qbFile = QBContent.uploadFileTask(file, true, (String) null);
user.setWebsite(qbFile.getPublicUrl());
user.setFileId(qbFile.getId());
return updateUser(user);
}
public void resetPassword(String email) throws QBResponseException {
QBAuth.createSession();
QBUsers.resetPassword(email);
}
}
我仍然需要" Token Required"问题,不知道我在这里做错了什么。
答案 0 :(得分:1)
如果在调用后出现,则在本机lib中出现调用错误。我们现在正在研究这个问题。在出现错误后继续在app中工作,你可以重新登录。它将重新初始化模块。