SyncUser.getRefreshToken() is package-local, shouldn't it be public?
See original GitHub issueGoal
What do you want to achieve?
Login with a previous non-expired session.
Expected Results
Successful login and synchronization
Actual Results
Cannot login with previous token since SyncUser does not expose
getRefreshToken()anymore.
I managed to find some code that uses reflection to access this method, but I don’t believe this should be the way.
Steps code to reproduce
SyncCredentials creds = SyncCredentials.usernamePassword("xxxxxxxxxx", "xxxxxxxxxxx");
SyncUser.Callback callback = new SyncUser.Callback<SyncUser>() {
@Override
public void onSuccess(SyncUser user) {
SyncConfiguration build = new SyncConfiguration.Builder(user, REALM_URL)
.waitForInitialRemoteData()
.modules(new CnaRealmModule())
.build();
Realm.setDefaultConfiguration(build);
Token refreshToken = getRefreshToken(user);
// prefs.realmRefreshToken()
}
public void onError(ObjectServerError error) {
String errorMsg;
switch (error.getErrorCode()) {
case UNKNOWN_ACCOUNT:
errorMsg = "Account does not exists.";
break;
case INVALID_CREDENTIALS:
errorMsg = "User name and password does not match";
break;
default:
errorMsg = error.toString();
}
Log.d(TAG, errorMsg);
Toast.makeText(LoginActivity.this, errorMsg, Toast.LENGTH_SHORT).show();
}
};
SyncUser.loginAsync(creds, REALM_AUTH_URL, callback);
Version of Realm and tooling
Realm version(s): 4.2.0
Realm sync feature enabled: yes
Android Studio version: 3.1.0
Which Android version and device: -
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Where to store the refresh token on the Client? - Stack Overflow
Access token and refresh token shouldn't be stored in the local/session storage, because they are not a place for any sensitive data. Hence...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Worked like charm. Thanks! Documentation should be updated mentioning this.
The
SyncUseris serialized to disk and read next time you ask for it, so it will not be null if you don’t log out that user.