[英]Android: AWS Amplify User State is not getting update
I have just started learning AWS Amplify and I am integrating it to my android project to authenticate users.我刚刚开始学习 AWS Amplify,并将其集成到我的 android 项目中以对用户进行身份验证。 I have successfully logged-in but
UserState
is still SIGNED_OUT
.我已经成功登录,但
UserState
仍然是SIGNED_OUT
。
AWSMobileClient.getInstance().signIn(userName, password, null, callback)
Callback Code snippet回调代码片段
fun fetchAuthenticationCallBack(): Callback<SignInResult> {
return object : Callback<SignInResult> {
override fun onResult(result: SignInResult?) {
when (result?.signInState) {
SignInState.DONE -> {
// AWSMobileClient.getInstance().confirmSignIn()
Log.d(TAG, "LOGIN SUCCESS ${AWSMobileClient.getInstance().tokens.accessToken}")
}
SignInState.NEW_PASSWORD_REQUIRED -> {
Log.d(TAG, "NEW PASSWORD CHALLENGE")
}
else -> {
// Unsupported sign-in confirmation:
}
}
}
override fun onError(e: java.lang.Exception?) {
TODO("Not yet implemented")
}
}
}
I want to get the accessToken but it gives me Exception我想获得 accessToken 但它给了我异常
Token does not support retrieving while user is SIGN_OUT
Is there anything that I am missing in the authentication part?我在身份验证部分有什么遗漏吗?
If anyone will face this issue in the future.如果将来有人会遇到这个问题。
Kindly check your awsconfiguration.json
file there is something went wrong.请检查您的
awsconfiguration.json
文件是否有问题。 In my case CognitoIdentity
credentials were wrong.就我而言,
CognitoIdentity
凭据是错误的。 I have just fixed the awsconfiguration.json
file everything is working as expected我刚刚修复了
awsconfiguration.json
文件,一切都按预期工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.