[英]Android: AWS Amplify User State is not getting update
我剛剛開始學習 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
我在身份驗證部分有什么遺漏嗎?
如果將來有人會遇到這個問題。
請檢查您的awsconfiguration.json
文件是否有問題。 就我而言, CognitoIdentity
憑據是錯誤的。 我剛剛修復了awsconfiguration.json
文件,一切都按預期工作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.