Amplify-js: Auth.federatedSignIn error: `AuthClass - Cannot get the current user because the user pool is missing

Created on 17 Jul 2019  路  5Comments  路  Source: aws-amplify/amplify-js

This issue reopens #2603

Describe the bug
When calling Auth.federatedSignIn(AuthProvider.developer, tokenResponse, federatedUser); the following error message is displayed in the console [ERROR] 05:59.887 AuthClass - Cannot get the current user because the user pool is missing. Please make sure the Auth module is configured with a valid Cognito User Pool ID.

The functionality seems to otherwise work.

To Reproduce
Steps to reproduce the behavior:

  1. Attain a token from a developer authentication provider. The token is generated server side using the call cognitoidentity.getOpenIdTokenForDeveloperIdentity().
  2. Pass the token into Auth.federatedSignIn() using the legacy provider call signature.

Expected behavior
I am using Cognito Identity Pools rather than User Pools, I would not expect any requirement to configure a User Pool or a error message in the console.

Screenshots
NA

Desktop (please complete the following information):

  • OS: Mac OS
  • Browser: Chrome 75.0.3770.100
  • Development Stack: Ionic 4, Angular 7, typescript 3.1.6

Additional context
From reviewing the amplify-js code, this appears to occur as a result of Auth.currentAuthenticatedUser() being called as part of Auth.federatedSignIn() to validate that there is no existing user sessions prior to authentication.

The Auth.currentAuthenticatedUser() function is using the presence of aws-amplify-federatedInfo in _storage to determine if federated authentication is being used. However this is still not set at the point at the call to Auth.currentAuthenticatedUser() is made prior to authentication which presumably creates the storage entry.

There is a type guard in Auth.federatedSignIn() which prevents this for FederatedSignInOptions(providerOrOptions) || isFederatedSignInOptionsCustom however this does not (as far as I can tell) catch this for the call signature where a legacy-provider is supplied, which is the signature I am using.

Sample code

import { FederatedResponse, FederatedUser } from '@aws-amplify/auth/lib/types'

const federatedUser: FederatedUser = {
    name: refreshdata.name,
    email: refreshdata.email
};
const tokenResponse: FederatedResponse = {
      identity_id: authdata.sub,
      token: response.authorization_token,
      expires_at: authdata.exp
};
await Auth.federatedSignIn('developer', tokenResponse, federatedUser);
Auth pending-close-response-required

Most helpful comment

I'm also getting this, I don't have multiple versions of aws-amplify installed.

All 5 comments

@mcroker - This error can occur when there are multiple versions of aws-amplify in your dependencies - for example, there is one at the root level, but another as a dependency of aws-amplify-angular or another package. Have you tried looking for this, or reinstalling your node_modules?

I don't believe this is the cause of my issue, I only have one version of aws-amplify in node_modules, and just to make sure I have just deleted / reinstalled my node_modules, and deleted & rebuilt /www (ionic).

martins-mbp:client-main martin$ find node_modules -type d -name "amplify"
node_modules/@aws-amplify
node_modules/aws-amplify
node_modules/aws-amplify-angular

I'm fairly confident from reviewing the code that this is a bug in Auth that happens only when the legacy provider call-signature is used for Auth.federatedSignIn.

I'm also getting this, I don't have multiple versions of aws-amplify installed.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

guanzo picture guanzo  路  3Comments

rayhaanq picture rayhaanq  路  3Comments

epicfaace picture epicfaace  路  3Comments

ddemoll picture ddemoll  路  3Comments

callmekatootie picture callmekatootie  路  3Comments