Im struggling getting user token after successfully logging in. The only thing I got is the current userId and username, but I cant get in any point the user tokens.
func login(userData: RegistrationFields) {
_ = Amplify.Auth.signIn(username: userData.email.data, password: userData.password.data) {
[weak self] result in
switch result {
case .success(let signInResult):
if signInResult.isSignedIn {
self?.getCurrentUser()
debugPrint("Sign in succeeded")
}
case .failure(let error):
debugPrint("Sign in failed \(error)")
self?.authStateDelegate?.authState(state: .error(error: error))
}
}
}
func getCurrentUser() {
guard let user = Amplify.Auth.getCurrentUser() else {return}
self.authStateDelegate?.authState(state: .session(user: user))
}