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:
cognitoidentity.getOpenIdTokenForDeveloperIdentity().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):
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);
@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
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.
Most helpful comment
I'm also getting this, I don't have multiple versions of aws-amplify installed.