我刚刚开始学习 AWS Amplify,并将其集成到我的 android 项目中以对用户进行身份验证。我已成功登录,但UserState
仍然是SIGNED_OUT
.
AWSMobileClient.getInstance().signIn(userName, password, null, callback)
回调代码片段
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")
}
}
}
我想获得 accessToken 但它给了我异常
Token does not support retrieving while user is SIGN_OUT
我在身份验证部分有什么遗漏吗?