What is the best practice to switch accounts without re login?
- Dominant language
- Java
- Stars
- 64
- Forks
- 66
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
My application uses multiple cloud providers and for each provider uses multiple accounts.
Once I create an account I store the accessToken and the refreshtoken etc ... in database.
Then when I want to reconnect or change account here is how I proceed:
```java
// inition of BoxConfig
BoxConfig.IS_LOG_ENABLED = false; //<------???
BoxConfig.CLIENT_ID = BOX_CLIENT_ID;
BoxConfig.CLIENT_SECRET = BOX_CLIENT_SECRET;
BoxConfig.REDIRECT_URL = "https://localhost";
mBoxSession = new BoxSession(getActivity(),null);
// here i set the stored accessToken and refreshtoken for a given account
mBoxSession.getAuthInfo().setAccessToken(item.accessToken);
mBoxSession.getAuthInfo().setRefreshToken(item.refreshToken);
mBoxSession.authenticate().addOnCompletedListener(new
BoxFutureTask.OnCompletedListener() {
@Override
public void onCompleted(BoxResponse response) {
if (response.isSuccess()) {
// if success i do my stuff
} else {
// if not i call onRefreshed
onRefreshed(mBoxSession.getAuthInfo());
}
}
});
@Override
public void onRefreshed(final BoxAuthentication.BoxAuthenticationInfo info) {
// here i set the new accessToken and refreshToken
currentBoxAccessToken = info.accessToken();
currentBoxRefreshToken = info.refreshToken();
mBoxSession.getAuthInfo().setAccessToken(currentBoxAccessToken);
mBoxSession.getAuthInfo().setRefreshToken(currentBoxRefreshToken);
mFolderApi = null;
mFileApi = null;
// and i store the new access and refresh token
// and finaly i do my previous stuff
}
```
But that does not prevent sometimes that the view of login appears ???
Contributor guide
Assessment
This issue has not been assessed yet.