[英]AWS Amplify Auth - Error when fetching user attributes of a signed in user
我正在嘗試在我的Android
應用程序中使用AWS Amplify Auth
。 注冊和登錄有效,現在我正在嘗試獲取已登錄用戶的用戶屬性,但 Amplify 在Amplify.Auth.fetchUserAttributes()
function 中拋出異常。
我的登錄代碼:
private void login(String email, String password) {
Amplify.Auth.signIn(
email,
password,
result -> {
if (result.isSignInComplete()) {
Log.i(TAG, "Sign in succeeded");
Log.i(TAG, "going to fetch User attributes");
Amplify.Auth.fetchUserAttributes(
attributes -> Log.i("AuthDemo", "User attributes = " + attributes.toString()),
error -> Log.e("AuthDemo", "Failed to fetch user attributes.", error)
);
Log.i(TAG, "end of fetching User attributes");
} else {
Log.i(TAG, "Sign in not complete");
}
},
error -> Log.e(TAG, error.toString())
);
}
日志:
I/LoginActivity: Sign in succeeded
W/InternalCallback: Library attempted to call user callback twice, expected only once
I/LoginActivity: going to fetch User attributes
D/AWSMobileClient: Inspecting user state details
D/AWSMobileClient: waitForSignIn: userState:SIGNED_OUT
E/AuthDemo: Failed to fetch user attributes.
AuthException{message=Failed to fetch user attributes, cause=java.lang.Exception: Operation requires a signed-in state, recoverySuggestion=Ensure that you are logged in and online}
at com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin$15.onError(AWSCognitoAuthPlugin.java:736)
....
Caused by: java.lang.Exception: Operation requires a signed-in state
...
它告訴我用戶 state 是:SIGNED_OUT,但我在成功登錄方法中調用它,那么為什么用戶退出了?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.