{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-java/issues/5573","repository_url":"https://api.github.com/repos/realm/realm-java","labels_url":"https://api.github.com/repos/realm/realm-java/issues/5573/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-java/issues/5573/comments","events_url":"https://api.github.com/repos/realm/realm-java/issues/5573/events","html_url":"https://github.com/realm/realm-java/issues/5573","id":277149975,"number":5573,"title":"SyncUser.getRefreshToken() is package-local, shouldn't it be public?","user":{"login":"mdumrauf","id":1047525,"avatar_url":"https://avatars2.githubusercontent.com/u/1047525?v=4","gravatar_id":"","url":"https://api.github.com/users/mdumrauf","html_url":"https://github.com/mdumrauf","followers_url":"https://api.github.com/users/mdumrauf/followers","following_url":"https://api.github.com/users/mdumrauf/following{/other_user}","gists_url":"https://api.github.com/users/mdumrauf/gists{/gist_id}","starred_url":"https://api.github.com/users/mdumrauf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdumrauf/subscriptions","organizations_url":"https://api.github.com/users/mdumrauf/orgs","repos_url":"https://api.github.com/users/mdumrauf/repos","events_url":"https://api.github.com/users/mdumrauf/events{/privacy}","received_events_url":"https://api.github.com/users/mdumrauf/received_events","type":"User","site_admin":false},"labels":[{"id":3545600,"url":"https://api.github.com/repos/realm/realm-java/labels/T:Help","name":"T:Help","color":"cc317c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-11-27T20:02:09Z","updated_at":"2017-11-28T14:39:54Z","closed_at":null,"author_association":"NONE","body":"#### Goal\r\n\r\n> What do you want to achieve?\r\n\r\nLogin with a previous non-expired session.\r\n\r\n#### Expected Results\r\n\r\n> Successful login and synchronization \r\n\r\n#### Actual Results\r\n\r\n> Cannot login with previous token since SyncUser does not expose `getRefreshToken()` anymore.\r\n\r\nI managed to find [some code that uses reflection](https://github.com/realm/realm-java/blob/3f6844a3cc82859d746437b4c4106c13601222f4/realm/realm-library/src/androidTestObjectServer/java/io/realm/util/SyncTestUtils.java#L112) to access this method, but I don't believe this should be the way.\r\n\r\n#### Steps code to reproduce\r\n\r\n```\r\nSyncCredentials creds = SyncCredentials.usernamePassword(\"xxxxxxxxxx\", \"xxxxxxxxxxx\");\r\n\r\nSyncUser.Callback callback = new SyncUser.Callback<SyncUser>() {\r\n    @Override\r\n    public void onSuccess(SyncUser user) {\r\n        SyncConfiguration build = new SyncConfiguration.Builder(user, REALM_URL)\r\n                .waitForInitialRemoteData()\r\n                .modules(new CnaRealmModule())\r\n                .build();\r\n        Realm.setDefaultConfiguration(build);\r\n\r\n        Token refreshToken = getRefreshToken(user);\r\n\r\n//      prefs.realmRefreshToken()\r\n\r\n    }\r\n\r\n    public void onError(ObjectServerError error) {\r\n        String errorMsg;\r\n        switch (error.getErrorCode()) {\r\n            case UNKNOWN_ACCOUNT:\r\n                errorMsg = \"Account does not exists.\";\r\n                break;\r\n            case INVALID_CREDENTIALS:\r\n                errorMsg = \"User name and password does not match\";\r\n                break;\r\n            default:\r\n                errorMsg = error.toString();\r\n        }\r\n        Log.d(TAG, errorMsg);\r\n        Toast.makeText(LoginActivity.this, errorMsg, Toast.LENGTH_SHORT).show();\r\n    }\r\n};\r\nSyncUser.loginAsync(creds, REALM_AUTH_URL, callback);\r\n```\r\n\r\n#### Version of Realm and tooling\r\nRealm version(s): 4.2.0\r\n\r\nRealm sync feature enabled: yes\r\n\r\nAndroid Studio version: 3.1.0\r\n\r\nWhich Android version and device: -\r\n"},"comment":{"url":"https://api.github.com/repos/realm/realm-java/issues/comments/347543679","html_url":"https://github.com/realm/realm-java/issues/5573#issuecomment-347543679","issue_url":"https://api.github.com/repos/realm/realm-java/issues/5573","id":347543679,"user":{"login":"mdumrauf","id":1047525,"avatar_url":"https://avatars2.githubusercontent.com/u/1047525?v=4","gravatar_id":"","url":"https://api.github.com/users/mdumrauf","html_url":"https://github.com/mdumrauf","followers_url":"https://api.github.com/users/mdumrauf/followers","following_url":"https://api.github.com/users/mdumrauf/following{/other_user}","gists_url":"https://api.github.com/users/mdumrauf/gists{/gist_id}","starred_url":"https://api.github.com/users/mdumrauf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdumrauf/subscriptions","organizations_url":"https://api.github.com/users/mdumrauf/orgs","repos_url":"https://api.github.com/users/mdumrauf/repos","events_url":"https://api.github.com/users/mdumrauf/events{/privacy}","received_events_url":"https://api.github.com/users/mdumrauf/received_events","type":"User","site_admin":false},"created_at":"2017-11-28T14:39:54Z","updated_at":"2017-11-28T14:39:54Z","author_association":"NONE","body":"The main reason is to be able to login offline using `SyncCredentials.accessToken(refreshToken, identifier)` instead of using basic login which would require internet if I need to sync the first session, and retrieve local db."}}
{"actor":{"display_login":"mdumrauf"}}