Do you want to request a feature or report a bug?
bug
What is the current behavior?
Auth.currentAuthenticatedUser() does not resolve nor does it throw a catchable error.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than AWS Amplify.
In a React Native application built using Expo I have the following code (debugger statements inserted to confirm execution location).
debugger;
Auth.currentAuthenticatedUser()
.then(res => {
debugger;
console.log('current user info: \n', res);
})
.catch(err => {
debugger;
console.log(err);
});
Only the first debugger statement which is prior to execution is reached. Additionally, nothing is logged to the console.
This code is called after a successfully using Auth.signIn() which returns the following CognitoUser object:

What is the expected behavior?
If there is an error, I expect to receive something that I can catch
Which versions of Amplify, and which browser / OS are affected by this issue? Did this work in previous versions?
"aws-amplify": "^0.4.4",
"aws-amplify-react-native": "^0.2.15",
"expo": "^27.0.0",
You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = 'DEBUG'; in your app.
@reggie3 can you open the debug mode to check what happened when that function was called?
I'm having problem with the Auth.currentAuthenticatedUser() method, there are times I call it, and Promise does not return either then() or catch().
I activated the debug mode Amplify.Logger.LOG_LEVEL = 'DEBUG'; below are the AuthClass outputs.
[DEBUG] 58:59.907 AuthClass - getting current credntials
[DEBUG] 58:59.909 AuthClass - picking up credentials
[DEBUG] 58:59.911 AuthClass - getting old cred promise
[DEBUG] 59:04.558 AuthClass - getting current authenticted user
Get item: key is federatedUser with options undefined
Thank you in advance, I await a return
I too have the same problem.
"aws-amplify": "^0.4.7",
"aws-amplify-react-native": "^0.2.18",
"react-native": "^0.55.4",
"react": "16.3.1",
@supermock sorry to be late. Can you provide more debug info since I can't tell what's happening based on the those logs.
@ishanthilina please provide more details or logs so I can reproduce it.
I am experiencing this on Android simulator:
In production, we have a problem that may be related or not: on a public WiFi which requires SignIn and before the WiFi Sign-in the currentAuthenticatedUser does fail to return the previous Authed user. Trying the above I tried to reproduce this error.
i'm facing the same problem
"aws-amplify": "1.0.0",
"aws-amplify-react-native": "1.0.0",
"react": "16.3.1",
"react-native": "~0.55.3",
Did anyone manage to find a workaround at least?
@powerful23 Following is a complete log.
(index):172 Console was cleared
ConsoleLogger.js:100 {[DEBUG] 00:03.745 Amplify - amplify config: {鈥}
ConsoleLogger.js:84 [DEBUG] 00:03.750 I18n - configure I18n
ConsoleLogger.js:84 [DEBUG] 00:03.750 I18n - create I18n instance
ConsoleLogger.js:90 {[DEBUG] 00:03.751 I18n: undefined}
ConsoleLogger.js:84 [DEBUG] 00:03.752 AuthClass - configure Auth
ConsoleLogger.js:100 {[DEBUG] 00:03.752 Parser - parse config: Array(3)}
ConsoleLogger.js:100 {[DEBUG] 00:03.755 Analytics - on hub capsule auth: {鈥}
ConsoleLogger.js:84 [DEBUG] 00:03.755 AnalyticsClass - configure Analytics
ConsoleLogger.js:100 {[DEBUG] 00:03.755 Parser - parse config: Array(3)}
ConsoleLogger.js:106 {[DEBUG] 00:03.757 DeviceInfo: Array(2)}
ConsoleLogger.js:100 {[DEBUG] 00:03.758 AWSPinpointProvider - configure Analytics: {鈥}
ConsoleLogger.js:100 {[DEBUG] 00:03.759 Analytics - on hub capsule analytics: {鈥}
ConsoleLogger.js:84 [DEBUG] 00:03.760 AnalyticsClass - configure Analytics
ConsoleLogger.js:84 [DEBUG] 00:03.763 AuthClass - getting current credntials
ConsoleLogger.js:84 [DEBUG] 00:03.763 Credentials - getting credentials
ConsoleLogger.js:84 [DEBUG] 00:03.764 Credentials - picking up credentials
ConsoleLogger.js:84 [DEBUG] 00:03.765 Credentials - getting new cred promise
ConsoleLogger.js:84 [DEBUG] 00:03.766 Credentials - checking if credentials exists and not expired
ConsoleLogger.js:84 [DEBUG] 00:03.766 Credentials - need to get a new credential or refresh the existing one
ConsoleLogger.js:84 [DEBUG] 00:03.768 AuthClass - Getting current user credentials
AsyncStorageCache.js:526 Get item: key is federatedInfo with options undefined
ConsoleLogger.js:100 {[DEBUG] 00:03.772 AnalyticsClass - current configuration: {鈥}
ConsoleLogger.js:84 [DEBUG] 00:03.772 Storage - configure called
ConsoleLogger.js:84 [DEBUG] 00:03.772 StorageClass - configure Storage
ConsoleLogger.js:84 [DEBUG] 00:03.772 StorageClass - Do not have bucket yet
ConsoleLogger.js:84 [DEBUG] 00:03.773 StorageClass - configure Storage
ConsoleLogger.js:84 [DEBUG] 00:03.773 StorageClass - Do not have bucket yet
ConsoleLogger.js:100 {[DEBUG] 00:03.774 PubSub - configure PubSub: {鈥}
ConsoleLogger.js:100 {[DEBUG] 00:03.775 API - configure API: {鈥}
ConsoleLogger.js:84 [DEBUG] 00:03.775 API - create API instance
ConsoleLogger.js:100 {[DEBUG] 00:03.776 RestClient - API Options: {鈥}
ConsoleLogger.js:100 {[DEBUG] 00:03.777 Interactions - configure Interactions: {鈥}
infoLog.js:15 Running application "testnamereplaced" with appParams: {"rootTag":291}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
AuthChecker.js:63 Auth Checker
AuthChecker.js:64 {screenProps: undefined, navigation: {鈥, auth: {鈥, dispatch: 茠}
AuthChecker.js:33 before await componentDidMount
ConsoleLogger.js:84 [DEBUG] 00:04.328 AuthClass - getting current authenticted user
AsyncStorageCache.js:526 Get item: key is federatedInfo with options undefined
ConsoleLogger.js:84 [DEBUG] 00:04.329 AuthClass - getting current authenticted user
AsyncStorageCache.js:526 Get item: key is federatedInfo with options undefined
ConsoleLogger.js:84 [DEBUG] 00:04.335 AuthClass - getting current credntials
ConsoleLogger.js:84 [DEBUG] 00:04.335 Credentials - getting credentials
ConsoleLogger.js:84 [DEBUG] 00:04.335 Credentials - picking up credentials
ConsoleLogger.js:84 [DEBUG] 00:04.335 Credentials - getting old cred promise
ConsoleLogger.js:84 [DEBUG] 00:04.337 AuthClass - get current authenticated userpool user
ConsoleLogger.js:84 [DEBUG] 00:04.337 AuthClass - get current authenticated userpool user
YellowBox.js:80 Remote debugger is in a background tab which may cause apps to perform slowly. Fix this by foregrounding the tab (or opening it in a separate window).
console.warn @ YellowBox.js:80
(anonymous) @ debuggerWorker.js:23
(anonymous) @ debuggerWorker.js:51
@ishanthilina the logging seems fine to me. I tried on my own machine with a blank new react native app running in expo with [email protected] and it worked for me. Can you provide more details so I could have a chance to reproduce it?
restart and clear cache 'R', followed by actually quitting and restarting the packager fixed this for me
@powerful23
This problem still happens. Hopefully, the following details will be useful:
Debug Output:
[DEBUG] 41:57.51 AuthClass - getting current authenticted user
[DEBUG] 41:57.51 AuthClass - cannot load federated user from auth storage
[DEBUG] 41:57.52 AuthClass - get current authenticated userpool user
Code:
// function to check if there is already a currently authenticated user
checkIfUserAlreadySignedIn = () => {
debugger; // **This debug statement is reached
return this.props.Auth.currentAuthenticatedUser()
.then((res) => {
debugger; // **This debug statement is never reached
})
.catch((err) => {
debugger; // **This debug statement is never reached
return false;
});
};
The checkIfUserAlreadySignedInfunction is called from an async function using the code shown below:
debugger; // **This debug statement is reached
let alreadySignedIn = await this.checkIfUserAlreadySignedIn();
debugger; // **This debug statement is never reached
I've additionally tried calling curretAuthenticatedUser directly from the async function like so:
debugger; // **This debug statement is reached
let alreadySignedIn = await this.props.Auth.currentAuthenticatedUser();
debugger; // **This debug statement is never reached
At this point, I'm using Amplify 1.1.6
@reggie3 thanks for reporting. I found it might be caused by a missing catch in the Auth code. Have submitted a pr to fix that.
@powerful23 Thanks. Do you know when a version of aws-amplify will get published with your PR now that it's been merged?
@reggie3 I am not sure but we will do that ASAP.
what was the outcome of this?
Most helpful comment
what was the outcome of this?