amplify-js: Federated Sign In - NoUserPoolError: Authentication Error

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):

  • OS: MacOS 10.14.6
  • Browser: Chrome
  • Version: 76.0.3809.132

Any advice much appreciated.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 18 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks, but I have updated to aws-amplify@1.1.40 and still see the error.

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 😃

Hi - any updates on this issue? Release 1.1.40 did not solve the problem unfortunately.

HI @elorzafe,

We did a release today that fix this problem. (aws-amplify@1.1.40) 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