aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.44k stars 2.13k forks source link

SignIn call gave error - AuthUserPoolException: Auth UserPool not configured. #14042

Open Sneha-Syngenta opened 3 days ago

Sneha-Syngenta commented 3 days ago

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

Authentication, REST API, GraphQL API

Amplify Version

v6

Amplify Categories

auth, function

Backend

None

Environment information

Hi I am also facing configuration issue while migrating from AWS Amplify v5 to v6. Amplify configuration is as follows: ``` import { Amplify } from 'aws-amplify'; Amplify.configure({ Auth: { Cognito: { userPoolId: process.env.REACT_APP_COGNITO_USER_POOL_ID || '', userPoolClientId: process.env.REACT_APP_COGNITO_APP_CLIENT_ID || '', }, }, }); ``` However, I am receiving the error: AuthUserPoolException: Auth UserPool not configured. aws amplify signIn code: ``` try { const { nextStep } = await signIn({ username: email, password: password, options: { country_code: modalDetails?.data?.country_code, }, }); if (nextStep?.signInStep === 'CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED') { setIsNewPasswordRequired(true); setIsButtonLoading(false); return; } updateLocalesToDB(); } catch (ex) { throw new Error( getErrorMessageByCognito((ex as Error)?.message, [CognitoPrefix.PreAuthentication]) ); } ``` I tried printing configuration, the configuration are getting called. it returns following object: ``` { "Auth": { "Cognito": { "userPoolId": "app-userPoolId", "userPoolClientId": "app-userPoolClientId" } }, "API": { "REST": { "YourAPIName": { "endpoint": "app-endpoint", "region": "app-region" } } } } ```

Describe the bug

At the time of login getting following error.

aws-amplify SignIn call gave error - AuthUserPoolException: Auth UserPool not configured.

Expected behavior

It should successfully do the login.

Reproduction steps

install: "aws-amplify": "^6.6.7",

Code Snippet:


  try {
        const { nextStep } = await signIn({
          username: email,
          password: password,
          options: {
            country_code: modalDetails?.data?.country_code,
          },
        });

        if (nextStep?.signInStep === 'CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED') {
          setIsNewPasswordRequired(true);
          setIsButtonLoading(false);
          return;
        }
        updateLocalesToDB(); / / This request should happen asynchronously, so not putting await
      } catch (ex) {
        throw new Error(
          getErrorMessageByCognito((ex as Error)?.message, [CognitoPrefix.PreAuthentication])
        );
      }

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

ashwinkumar6 commented 2 days ago

Hi @Sneha-Syngenta thanks for raising the issue, Could you please try double check the following

Sneha-Syngenta commented 2 hours ago

Thank you for your response.

I did verified this already, config are getting called with proper values whatever we have defined in amplify.config.

it returns following object:

{
    "Auth": {
        "Cognito": {
            "userPoolId": "app-userPoolId",
            "userPoolClientId": "app-userPoolClientId"
        }
    },
    "API": {
        "REST": {
            "YourAPIName": {
                "endpoint": "app-endpoint",
                "region": "app-region"
            }
        }
    }
}

But somehow it is giving above error.