Describe the bug
Using Amplify with AWS AppSync and federated sign in for real-time chat in our Angular 7 app. Issue appears similar to https://github.com/aws-amplify/amplify-js/issues/2445.
The implementation seems to work correctly in terms of functionality and afterwards it seems to recognise the current authenticated user, but I get this NoUserPoolError nonetheless. Debug logs:
[DEBUG] 47:01.813 AuthClass - getting current authenticated user
console.js:35
[DEBUG] 47:01.814 AuthClass - cannot load federated user from auth storage
console.js:35
[DEBUG] 47:01.814 AuthClass - get current authenticated userpool user
[ERROR] 47:01.815 AuthError -
Error: Amplify has not been configured correctly.
The configuration object is missing required auth properties.
[DEBUG] 47:01.820 AuthClass - The user is not authenticated by the error NoUserPoolError: Authentication Error
[DEBUG] 47:02.393 Credentials - Load credentials successfully
[INFO] 47:02.394 Cache - Set item: key is federatedInfo, value is [object Object] with options: [object Object]
console.js:35
[DEBUG] 47:02.395 AuthClass - getting current authenticated user
console.js:35
[DEBUG] 47:02.396 AuthClass - get current authenticated federated user {id: "eu-west-1:XXXXXXXXXXXXXXX", name: ""}
Amplify config:
import Amplify, { Auth } from 'aws-amplify';
Amplify.configure({
Auth: {
identityPoolId: eu-west-1:XXXXXXXXXX,
region: 'eu-west-1',
mandatorySignIn: false
},
aws_appsync_region: 'eu-west-1',
aws_appsync_graphqlEndpoint: https://XXXXXXXXXX.appsync-api.eu-west-1.amazonaws.com/graphql,
aws_appsync_authenticationType: 'AWS_IAM'
});
package.json:
"aws-amplify": "^1.1.38",
"aws-appsync": "^1.7.1",
The similar issue detailed in https://github.com/aws-amplify/amplify-js/issues/2445 was solved by removing the cookie storage from the config but as you can see we do not use that.
In the same way as the above issue we're not using cognito user pools - only a cognito identity pool.
To Reproduce
Attempt federated sign in using the config
See error
Expected behavior
Successful auth with no errors
Desktop (please complete the following information):
Any advice much appreciated.
@GWilman the error is only on the console or you are seeing the error on your app as well?
How are you doing federation? It seems you also are using guest credentials for unauth users?
Thanks!
We do not allow unauthenticated identities, we use "Custom" in our Identity Pool settings aka "Developer Authenticated"
var params = {
IdentityPoolId: config.aws.appsync.chat.identity_pool_id,
Logins: {
'<Our Identity Pool Custom Auth Name>': <Our User's UUID>
},
TokenDuration: 3600
};
cognitoidentity.getOpenIdTokenForDeveloperIdentity(params, function(err, result) {
});
With regards to the error, this one is printed in the browser console:
[ERROR] 47:01.815 AuthError -
Error: Amplify has not been configured correctly.
The configuration object is missing required auth properties.
I switched on Amplify.Logger.LOG_LEVEL = 'DEBUG'; to see the rest.
We did a release today that fix this problem. ([email protected]) please confirm if that solved your problem.
Thanks, but I have updated to [email protected] and still see the error.
Hi - any updates on this issue? Release 1.1.40 did not solve the problem unfortunately.
Having the same error on React native where I'm using a shared configuration from web-app. Packages used are:
"@aws-amplify/api": "^1.1.3",
"@aws-amplify/auth": "^1.3.3",
"aws-amplify": "^1.1.40",
Just updated the packages to most recent versions and this error surfaced.
HI @elorzafe,
We did a release today that fix this problem. ([email protected]) please confirm if that solved your problem.
I was looking at the Auth class code and it seems odd to me that the currentAuthenticatedUser code decides whether the user is federated or not just based on the aws-amplify-federatedInfo key from storage. The case where this fails (and the case I am having trouble with) is the initial app load when the storage is empty. The problem with this case is that the code is trying to look for currentUserPoolUser where I don't have one as I am using Identity Pool Federation (just like @GWilman). The currentUserPoolUser then throws as no user pool is specified and all goes to red screen in ReactNative app.
Also, while looking at this, I am almost 100% sure that the Auth class is not using correct StorageHelper. It uses the one imported from @aws-amplify/core and there is no support for RN AsyncStorage there. What about StorageHelper-rn from amazon-cognito-identity-js.
Thanks
Also, I see a couple of pull requests (https://github.com/aws-amplify/amplify-js/pull/3991, https://github.com/aws-amplify/amplify-js/pull/4027) where the idea is to switch from AsyncStorage from react-native package to the one from "@react-native-community/async-storage"...
amazon-cognito-identity-js is using [email protected] in which AsyncStorage is present. No need for react-native upgrade and switching to community package. Right?
The problem that is causing this https://github.com/aws-amplify/amplify-js/issues/3956 is that the Auth class is not using correct StorageHelper.
@GWilman @darko-dev @plahteenlahti - Just to confirm the problem here: you are seeing this error, but the app still appears to be functioning properly?
@haverchuck that is correct - all functionality is fine and I see no more errors after this when using the app (using amplify api graphql operations etc.)
@GWilman - Thanks for the response. I think we have a fix for this, but it might take awhile to test.
@haverchuck thank you, please let me know once tested 馃憤
@GWilman If you want to take a look at the PR, it's here.
@haverchuck looks okay to me - is it likely to be merged soon? Thanks
@GWilman - We merged a fix for this into our unstable build (npm i aws-amplify@unstable or npm i @aws-amplify/auth@unstable). It will be in the main build when we do our next release.
@haverchuck That's great. Thank you.
This worked form me on aws-amplify@^3.x.x
import Amplify, {Auth} from 'aws-amplify';
import aws_exports from './aws-exports';
Amplify.configure(aws_exports);
Auth.configure({
region: process.env.COGNITO_REGION,
userPoolId: process.env.COGNITO_USER_POOL_ID,
userPoolWebClientId: process.env.COGNITO_USER_POOL_WEB_CLIENT_ID,
authenticationFlowType: 'USER_PASSWORD_AUTH',
})
In the AWS Amplify auth JS documentation they suggest to use this: (But that triggers the noUserPoolError)
Amplify.configure({
Auth: {
key: val,
key2: val2
}
});
Hope that helps :)
Most helpful comment
Thanks, but I have updated to [email protected] and still see the error.