Describe the bug
Hi! We use CustomAuthentification to exclude password from signing flow - only sms code into AWSCognitoIdentityCustomAuthentication
After handling success didCompleteStepWithError we try to get session from current user.
let awsUserPool = AWSCognitoIdentityUserPool(forKey: AWSCognitoUserPoolsSignInProviderKey)
var accessTokenString = ""
var idTokenString = ""
let currentUser = awsUserPool.currentUser()
currentUser?.getSession().continueWith(block: { (session) -> Any? in
if let accessToken = session.result?.accessToken,
let idToken = session.result?.idToken {
accessTokenString = accessToken.tokenString
idTokenString = idToken.tokenString
observer(.success((accessTokenString, idTokenString)))
} else {
observer(.error(RxError.noElements))
}
return nil
})
99% of users signed in success, but some users have problem with getting session after Confirming code. getSession().continueWith(block: { (session) -> Any? in block has never called. We tried to retry 3 times with 3 second delay but had no success.
To Reproduce
Steps to reproduce the behavior:
I don't know how to reproduce it because this problem is very intermittent
Observed Behavior
Expected Behavior
getSession().continueWith(block: { (session) -> Any? in block should be called
Unique Configuration
Using customAuthenticationCompletion for AWSCognitoIdentityInteractiveAuthenticationDelegate
Areas of the SDK you are using (AWSMobileClient, Cognito, Pinpoint, IoT, etc)?
Signin and Signup
Environment(please complete the following information):
Device Information (please complete the following information):
getSession() can block on other Cognito delegate methods. Have you fully implemented all of the User Pool delegate methods to ensure there isn't a case where some of your users are being caught by these? Even though you're implementing custom auth, I wonder if there may be some case that is triggering one of these callbacks.
@palpatim
https://gist.github.com/abonko/148bba1d68e4dadca3283fc828080157 source of auth manager that wraps AWSCognitoIdentityCustomAuthentication.
Have you fully implemented all of the User Pool delegate methods to ensure there isn't a case where some of your users are being caught by these?
We implemented only startCustomAuthentication method. Other methods are not used in our cases. How should we use these methods without using? E.x. startPasswordAuthentication.
@palpatim I have found such problem. User get code in sms and hide our app and go into message app. He remember the code and return back into our app to confirm code. BUT request from AWS SDK has now session id so AWS thought that it is new session but not confirmation. See log of requests https://gist.github.com/abonko/6a052218bfd8a03fb82cb61f87ccda70
If user do not hide the app second request has session parameter and AWS will confirm the code.
@palpatim I have found such problem. User get code in sms and hide our app and go into message app. He remember the code and return back into our app to confirm code. BUT request from AWS SDK has now session id so AWS thought that it is new session but not confirmation. See log of requests https://gist.github.com/abonko/6a052218bfd8a03fb82cb61f87ccda70
If user do not hide the app second request has session parameter and AWS will confirm the code.
After removing getSession on applicationDidBecomeActive method problem was fixed
Glad that you fixed the issue. You should have only one getSession request in between a respondToAuth call. The getSession call in app delegate might have cleared the session of the previous one.
I am closing this issue, feel free to reach out if you face any other issue.
Our team have struggled with this issue for around 6 months where the completion handler is never called and no error is thrown. It seems to happen a month or so after new users make accounts that they begin to have login issues but it is intermittent.
I can confirm the getUser method is only called once and we can have an identical account login fine on one device and not the other.
currentUser.getSession().continueWith { [weak self] getSessionTask -> Any? in
Most helpful comment
Our team have struggled with this issue for around 6 months where the completion handler is never called and no error is thrown. It seems to happen a month or so after new users make accounts that they begin to have login issues but it is intermittent.
I can confirm the
getUsermethod is only called once and we can have an identical account login fine on one device and not the other.currentUser.getSession().continueWith { [weak self] getSessionTask -> Any? in