【问题标题】:AWS auth seesion not keeping alive when we close the android application当我们关闭 android 应用程序时,AWS 身份验证会话没有保持活动状态
【发布时间】:2020-10-11 05:16:46
【问题描述】:

我正在使用 AWS Amplify SDK 进行 Cognito 集成。实际上,我根据可用的文档here 成功集成了用户登录和注册流程。但是,成功登录后,如果我们重新启动应用程序,则用户会话不会持续存在。 Amplify.Auth.fetchAuthSession() 总是以 false 返回 isSignedIn。我不知道我在哪里制造问题。请在下方找到“登录”sn-p。

fun onSingIn(view: View) {
    Amplify.Auth.signIn(
            email.value,
            password.value,
            { result ->
                Log.i(TAG, if (result.isSignInComplete) "Sign in succeeded" else "Sign in not complete")

                if (result.isSignInComplete) {
                    view.context.let {
                        it.startActivity(Intent(it, FeedActivity::class.java))
                        signInStatus.postValue(true)
                    }
                }

            },
            { error ->
                view.context.let {
                    var message = it.getString(R.string.something_went_wrong)
                    when (error.cause) {
                        is UserNotConfirmedException ->{
                            email.value?.let {emailAddress ->
                                val direction =LoginFragmentDirections
                                        .actionLoginFragmentToEmailVerificationCodeFragment(emailAddress)
                                view.findNavController().navigate(direction)
                            }
                        }
                        is UserNotFoundException ->
                            message = it.getString(R.string.credentilas_incorrect)
                        else->
                            viewModelScope.launch(Dispatchers.Main) { it.showToast(message) }
                    }
                    Log.e(TAG, error.toString())
                }

            }
    )
}

【问题讨论】:

    标签: android amazon-web-services amazon-cognito aws-amplify aws-userpools


    【解决方案1】:

    终于解决了这个问题。问题是相关的用户池应用程序客户端设置配置。 我没有在应用客户端设置中检查身份提供者。选择“Cognito 用户池”作为身份提供者后,登录会话保持活动状态,没有任何问题。希望这个答案能帮助遇到类似问题的人。

    【讨论】:

      猜你喜欢
      • 2023-03-04
      • 2021-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-20
      • 1970-01-01
      • 2022-06-22
      • 2014-11-14
      相关资源
      最近更新 更多