{"action":"created","issue":{"url":"https://api.github.com/repos/aws/aws-sdk-android/issues/390","repository_url":"https://api.github.com/repos/aws/aws-sdk-android","labels_url":"https://api.github.com/repos/aws/aws-sdk-android/issues/390/labels{/name}","comments_url":"https://api.github.com/repos/aws/aws-sdk-android/issues/390/comments","events_url":"https://api.github.com/repos/aws/aws-sdk-android/issues/390/events","html_url":"https://github.com/aws/aws-sdk-android/issues/390","id":285119998,"number":390,"title":"Id token and Access token are not refreshed automatically","user":{"login":"gmjgh","id":17403664,"avatar_url":"https://avatars2.githubusercontent.com/u/17403664?v=4","gravatar_id":"","url":"https://api.github.com/users/gmjgh","html_url":"https://github.com/gmjgh","followers_url":"https://api.github.com/users/gmjgh/followers","following_url":"https://api.github.com/users/gmjgh/following{/other_user}","gists_url":"https://api.github.com/users/gmjgh/gists{/gist_id}","starred_url":"https://api.github.com/users/gmjgh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmjgh/subscriptions","organizations_url":"https://api.github.com/users/gmjgh/orgs","repos_url":"https://api.github.com/users/gmjgh/repos","events_url":"https://api.github.com/users/gmjgh/events{/privacy}","received_events_url":"https://api.github.com/users/gmjgh/received_events","type":"User","site_admin":false},"labels":[{"id":690771494,"url":"https://api.github.com/repos/aws/aws-sdk-android/labels/UserPools","name":"UserPools","color":"1d76db","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-29T16:29:55Z","updated_at":"2018-04-11T07:48:27Z","closed_at":null,"author_association":"NONE","body":"### To help you solve my problem better here is the list of answers for your questions.\r\n\r\n* What service are you using? - Xiaomi Mi A1. Elephone p8000, Google Nexus X5\r\n\r\n* In what version of SDK are you facing the problem? - 2.6.11\r\n\r\n* Is the issue limited to Simulators / Actual Devices? - Actual\r\n\r\n* Can your problem be resolved if you bump to a higher version of SDK? - No\r\n\r\n* Is this problem related to specific Android/OS version? - No\r\n\r\n### Description of the problem.\r\nHello. I develop simple sign in/ sign up feature with Cognito for my app on Kotlin. \r\nI provide `CognitoPool` with Dagger 2\r\n   ```\r\n    @Provides\r\n    @Singleton\r\n    internal fun provideAWSCognito(context: Context): CognitoUserPool =\r\n            CognitoUserPool(context,\r\n                    BuildConfig.COGNITO_POOL_ID,\r\n                    BuildConfig.COGNITO_CLIENT_KEY,\r\n                    BuildConfig.COGNITO_CLIENT_SECRET,\r\n                    ClientConfiguration(),\r\n                    Regions.AP_SOUTHEAST_1)\r\n```\r\n\r\nAfter that I use it in my `AuthRepo` for authenticating users. I wrap it into RxJava2 for code consistency reasons.\r\n\r\n ```\r\n    @Inject\r\n    lateinit var userPool: CognitoUserPool\r\n\r\n    override fun login(email: String, password: String): Observable<CognitoUser> =\r\n            Flowable.create<CognitoUser>({ emitter ->\r\n                val details = AuthenticationDetails(email, password, null)\r\n                userPool.getUser(email).initiateUserAuthentication(details, object : AuthenticationHandler {\r\n                    override fun onSuccess(userSession: CognitoUserSession?, newDevice: CognitoDevice?) {\r\n                        userSession({\r\n                            emitter.onNext(userPool.currentUser)\r\n                        }, {\r\n                            emitter.onError(authError)\r\n                        })\r\n                        emitter.onComplete()\r\n\r\n                    }\r\n\r\n                    override fun onFailure(exception: Exception?) {\r\n                        emitter.onError(exception({ this }, { authError }))\r\n                        emitter.onComplete()\r\n                    }\r\n\r\n                    override fun getAuthenticationDetails(authenticationContinuation: AuthenticationContinuation?, userId: String?) {\r\n                        emitter.onError(authError)\r\n                        emitter.onComplete()\r\n                    }\r\n\r\n                    override fun authenticationChallenge(continuation: ChallengeContinuation?) {\r\n                        emitter.onError(authError)\r\n                        emitter.onComplete()\r\n                    }\r\n\r\n                    override fun getMFACode(continuation: MultiFactorAuthenticationContinuation?) {\r\n                        emitter.onError(authError)\r\n                        emitter.onComplete()\r\n                    }\r\n                }, false).run()\r\n            }, BackpressureStrategy.LATEST).toObservable()\r\n```\r\n\r\nIt works as expected - it logs user in and provides me with all 3 Tokens - Refresh, Access and Id.\r\n\r\nFor getting tokens I use `userPool.currentUser.getSession()` and wrap it into coroutine for usage convenience reasons. \r\n\r\n```\r\n    @Inject\r\n    lateinit var userPool: CognitoUserPool\r\n\r\n    private suspend fun token(): String? = suspendCoroutine { future ->\r\n        userPool.currentUser.getSession(object : AuthenticationHandler {\r\n            override fun onSuccess(userSession: CognitoUserSession?, newDevice: CognitoDevice?) {\r\n                userSession({\r\n                    future.resume(this.idToken.jwtToken)\r\n                }, {\r\n                    future.resume(null)\r\n                })\r\n            }\r\n\r\n            override fun onFailure(exception: Exception?) {\r\n                future.resume(null)\r\n            }\r\n\r\n            override fun getAuthenticationDetails(authenticationContinuation: AuthenticationContinuation?, userId: String?) {\r\n                future.resume(null)\r\n            }\r\n\r\n            override fun authenticationChallenge(continuation: ChallengeContinuation?) {\r\n                future.resume(null)\r\n            }\r\n\r\n            override fun getMFACode(continuation: MultiFactorAuthenticationContinuation?) {\r\n                future.resume(null)\r\n            }\r\n        })\r\n    }\r\n\r\n    override fun getToken(): String? = runBlocking(CommonPool) { token() }\r\n\r\n    override fun isLoggedIn() = getToken()({ true }, { false })\r\n\r\n```\r\nIt works as expected as well, but after one hour, when the token is expired, it always invokes `getAuthenticationDetails` and waits for me to provide `AuthenticationDetails` with email and password. I have an email but the password is not stored anywhere inside an app. The official documentation states that the SDK refreshes tokens automatically. **My question is why it does not refresh tokens automatically in my case - if there is something wrong with my code could you please point it out to me, if not - what could be the problem?** Thanks in advance.\r\n"},"comment":{"url":"https://api.github.com/repos/aws/aws-sdk-android/issues/comments/380360413","html_url":"https://github.com/aws/aws-sdk-android/issues/390#issuecomment-380360413","issue_url":"https://api.github.com/repos/aws/aws-sdk-android/issues/390","id":380360413,"user":{"login":"stale[bot]","id":26384082,"avatar_url":"https://avatars3.githubusercontent.com/in/1724?v=4","gravatar_id":"","url":"https://api.github.com/users/stale%5Bbot%5D","html_url":"https://github.com/apps/stale","followers_url":"https://api.github.com/users/stale%5Bbot%5D/followers","following_url":"https://api.github.com/users/stale%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/stale%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/stale%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stale%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/stale%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/stale%5Bbot%5D/repos","events_url":"https://api.github.com/users/stale%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/stale%5Bbot%5D/received_events","type":"Bot","site_admin":false},"created_at":"2018-04-11T07:48:27Z","updated_at":"2018-04-11T07:48:27Z","author_association":"NONE","body":"This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.\n"}}
{"actor":{"display_login":"stale"}}