Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks done
Sneha-Syngenta opened this issue Nov 29, 2024 · 10 comments
Open
3 tasks done
Assignees
Labels
Auth Related to Auth components/category pending-community-response Issue is pending a response from the author or community. question General question

Comments

@Sneha-Syngenta
Copy link

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

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending a response from the Amplify team. labels Nov 29, 2024
@ashwinkumar6
Copy link
Member

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

  • Amplify.configure is called at the root of your app (example index.js) so this gets configured first and then the signIn api gets called.
  • can you call Amplify.getConfig() right before calling signIn to check if the required configuration is present
  • Is it possible Amplify.configure might be called twice and one of the times userPoolId: process.env.REACT_APP_COGNITO_USER_POOL_ID || '' might result in an empty string

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Nov 29, 2024
@Sneha-Syngenta
Copy link
Author

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.

@github-actions github-actions bot added the pending-maintainer-response Issue is pending a response from the Amplify team. label Dec 2, 2024
@HuiSF
Copy link
Member

HuiSF commented Dec 2, 2024

Did you get a chance to validate what did Amplify.getConfig() return right before calling signIn() API?

@HuiSF HuiSF added the Auth Related to Auth components/category label Dec 2, 2024
@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Dec 2, 2024
@HuiSF HuiSF added the question General question label Dec 2, 2024
@github-actions github-actions bot removed the pending-triage Issue is pending triage label Dec 2, 2024
@cwomack cwomack self-assigned this Dec 10, 2024
@cwomack cwomack added the pending-community-response Issue is pending a response from the author or community. label Dec 10, 2024
@cwomack
Copy link
Member

cwomack commented Dec 10, 2024

@Sneha-Syngenta, wanted to ping you again to see if you're still blocked here or if you had a chance to validate what Amplify.getConfig() returns right before calling signIn(). Thanks!

@Sneha-Syngenta
Copy link
Author

Hi,

Thanks for your reply. I already shared in the previous msg that we did verified this

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.

@github-actions github-actions bot added pending-maintainer-response Issue is pending a response from the Amplify team. and removed pending-community-response Issue is pending a response from the author or community. labels Dec 12, 2024
@cwomack
Copy link
Member

cwomack commented Dec 12, 2024

@Sneha-Syngenta, can you share your package.json file so we can see what dependencies you have? And with this being a migration from v5 to v6, can you also do the following:

  • delete your package-lock.json file
  • delete your node_modules folder
  • reinstall dependencies with npm install

@cwomack cwomack added pending-community-response Issue is pending a response from the author or community. and removed pending-maintainer-response Issue is pending a response from the Amplify team. labels Dec 12, 2024
@Dinuja28
Copy link

Dinuja28 commented Dec 16, 2024

Hey @cwomack , I'm experiencing the same issue. I made sure to print out the config before my cognito-related function ran (sign in/out, etc.), and it indeed is printing out correctly. I also followed the instructions you gave above, but when my code calls the signIn API, I get the same error: "Auth user pool not configured."

I should also add that, for my team, we utilize Amplify for two of our microservices, and just last week both were working fine with no changes being made to the config, but now both services error out with "Auth user pool not configured."

@github-actions github-actions bot added pending-maintainer-response Issue is pending a response from the Amplify team. and removed pending-community-response Issue is pending a response from the author or community. labels Dec 16, 2024
@Sneha-Syngenta
Copy link
Author

@cwomack i did followed same step you mentioned in thread but somehow no luck.

issue still persist with same error "Auth UserPool not configured."

@Dinuja28
Copy link

Hey @cwomack , I'm experiencing the same issue. I made sure to print out the config before my cognito-related function ran (sign in/out, etc.), and it indeed is printing out correctly. I also followed the instructions you gave above, but when my code calls the signIn API, I get the same error: "Auth user pool not configured."

I should also add that, for my team, we utilize Amplify for two of our microservices, and just last week both were working fine with no changes being made to the config, but now both services error out with "Auth user pool not configured."

UPDATE: To anyone wondering, I figured out what was wrong with my implementation. The signIn API call was put into a function that was marked to "use server" (I'm using nextjs 14), which was being used within a server action, but the issue with this is that the config appears as an empty object, and that likely because the Amplify config is on the client side:

"use client";

import {Amplify, type ResourcesConfig} from "aws-amplify";

export const authConfig: ResourcesConfig["Auth"] = {
    Cognito: {
        userPoolId: String(process.env.NEXT_PUBLIC_USER_POOL_ID),
        userPoolClientId: String(process.env.NEXT_PUBLIC_USER_POOL_CLIENT_ID),
    },
};

Amplify.configure(
    {
        Auth: authConfig,
    },
    {
       ssr: true // use cookies for state storage over the default, local storage
    }
);

export default function ConfigureAmplifyClientSide(){
    return null;
}

Where as my signIn API call happens on the server (this executes first), and so, the fix is to remove the "use server" statement from the function call (or from the top of your file; if your Cognito actions are all in one file). Hope that helps. If my understanding of the way Amplify works with respect to client/server is wrong, please correct me, thanks!

@pranavosu
Copy link
Member

@cwomack i did followed same step you mentioned in thread but somehow no luck.

issue still persist with same error "Auth UserPool not configured."

There might be multiple versions of aws-amplify installed in node_modules. Can you try running npx npm-why aws-amplify in the app root folder ? This should give you a list of all the installed versions.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Dec 17, 2024
@cwomack cwomack added the pending-community-response Issue is pending a response from the author or community. label Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auth Related to Auth components/category pending-community-response Issue is pending a response from the author or community. question General question
Projects
None yet
Development

No branches or pull requests

6 participants