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

V3 to V6 upgrade causes AuthUserPoolException #13289

Open
3 tasks done
jgabriel98 opened this issue Apr 24, 2024 · 7 comments
Open
3 tasks done

V3 to V6 upgrade causes AuthUserPoolException #13289

jgabriel98 opened this issue Apr 24, 2024 · 7 comments
Assignees
Labels
Auth Related to Auth components/category question General question

Comments

@jgabriel98
Copy link

jgabriel98 commented Apr 24, 2024

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

Authentication

Amplify Version

v6

Amplify Categories

auth

Backend

None

Environment information

  System:
    OS: macOS 13.6.5
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 59.18 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 14.19.0 - ~/.nvm/versions/node/v14.19.0/bin/node
    npm: 6.14.16 - ~/.nvm/versions/node/v14.19.0/bin/npm
  Browsers:
    Chrome: 124.0.6367.79
    Safari: 17.4
  npmPackages:
    @adyen/adyen-web: 5.12.0 => 5.12.0 
    @emotion/react: ^11.10.5 => 11.11.4 
    @emotion/styled: ^11.10.5 => 11.11.0 
    @loggi/authentication: * => 0.1.0 
    @loggi/authentication-lib: * => 0.0.0 
    @loggi/components: * => 1.0.0 
    @loggi/front-design-system: 4.4.6 => 4.4.6 
    @loggi/front-design-tokens: 4.0.0 => 4.0.0 
    @loggi/loggi-icons: ^1.2.1 => 1.3.2 
    @loggi/mar: * => 0.0.0 
    @mui/icons-material: ^5.11.0 => 5.15.13 
    @mui/lab: ^5.0.0-alpha.114 => 5.0.0-alpha.168 
    @mui/material: ^5.11.3 => 5.15.13 
    @mui/styles: ^5.11.2 => 5.15.13 
    @playwright/test: 1.39.0 => 1.39.0 
    @tanstack/react-query: 4.29.5 => 4.29.5 
    @testing-library/user-event: 7.2.1 => 7.2.1 
    @xstate/react: ^3.2.2 => 3.2.2 
    aws-amplify: ^6.0.28 => 6.0.30 
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/enable-oauth-listener:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/data:  undefined ()
    aws-amplify/data/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
    detect-inapp: ^1.4.0 => 1.4.0 
    dotenv: 8.6.0 => 8.6.0 
    jest-when: ^3.6.0 => 3.6.0 
    logrocket: 3.0.1 => 3.0.1 
    logrocket-react: 5.0.1 => 5.0.1 
    notistack: 3.0.1 => 3.0.1 
    pwa-asset-generator: 2.3.0 => 2.3.0 
    react-focus-lock: 2.9.3 => 2.9.3 
    react-hotjar: 3.0.0 => 3.0.0 
    react-lottie: 1.2.3 => 1.2.3 
    rudder-sdk-js: ^2.42.3 => 2.48.3 
    singular-sdk: ^1.4.1 => 1.4.1 
    swiper: 8.0.7 => 8.0.7 
    swiper_angular:  0.0.1 
    use-local-storage-state: ~11.0.0 => 11.0.0 
    workbox-broadcast-update: 6.5.4 => 6.5.4 
    workbox-cacheable-response: 6.5.4 => 6.5.4 
    workbox-core: 6.5.4 => 6.5.4 
    workbox-expiration: 6.5.4 => 6.5.4 
    workbox-google-analytics: 6.5.4 => 6.5.4 
    workbox-precaching: 6.5.4 => 6.5.4 
    workbox-routing: 6.5.4 => 6.5.4 
    workbox-strategies: 6.5.4 => 6.5.4 
    workbox-window: 6.5.4 => 6.5.4 
    xstate: ^4.38.0 => 4.38.3 
  npmGlobalPackages:
    @aws-amplify/cli: 12.11.0
    @loggi/front-design-system: 5.3.0
    corepack: 0.10.0
    npm: 6.14.16

Describe the bug

Migrating from amplify v3 to v6, when calling signInWithRedirect() i get the error AuthUserPoolException: Auth UserPool not configured .


Note: i called Amplify.getConfig() right before signInWithRedirect() just to be sure: image
and it returned normally (console.log output):
image


old (amplify v3) Amplify.configure() call:

Amplify.configure({
  aws_project_region: process.env.REACT_APP_AWS_PROJECT_REGION,
  aws_cognito_identity_pool_id: process.env.REACT_APP_AWS_COGNITO_IDENT_POOL,
  aws_cognito_region: process.env.REACT_APP_AWS_PROJECT_REGION,
  aws_user_pools_id: process.env.REACT_APP_AWS_USER_POOL_ID,
  aws_user_pools_web_client_id: process.env.REACT_APP_AWS_WEB_CLIENT,
  oauth: {
    domain: process.env.REACT_APP_AWS_COGNITO_DOMAINANME,
    scope: [
      'phone',
      'email',
      'openid',
      'profile',
      'aws.cognito.signin.user.admin'
    ],
    redirectSignIn: process.env.REACT_APP_AWS_REDIRECT_SIGN_IN_BEYOND,
    redirectSignOut: process.env.REACT_APP_AWS_REDIRECT_SIGN_IN_BEYOND,
    responseType: 'code'
  },
  federationTarget: 'COGNITO_USER_POOLS'
})

new (amplify v6) Amplify.configure() call:

Amplify.configure({
  Auth: {
    identityPoolId: process.env.REACT_APP_AWS_COGNITO_IDENT_POOL,
    region: process.env.REACT_APP_AWS_PROJECT_REGION,
    userPoolWebClientId: process.env.REACT_APP_AWS_WEB_CLIENT,
    mandatorySignIn: true,

    Cognito: {
      userPoolId: process.env.REACT_APP_AWS_USER_POOL_ID,
      userPoolClientId: process.env.REACT_APP_AWS_WEB_CLIENT,
      identityPoolId: process.env.REACT_APP_AWS_COGNITO_IDENT_POOL,
      signUpVerificationMethod: 'code',
      loginWith: {
        oauth: {
          domain: process.env.REACT_APP_AWS_COGNITO_DOMAINANME,
          scopes: ['phone', 'email', 'openid', 'profile', 'aws.cognito.signin.user.admin'],
          redirectSignIn: [process.env.REACT_APP_AWS_REDIRECT_SIGN_IN_BEYOND],
          redirectSignOut: [process.env.REACT_APP_AWS_REDIRECT_SIGN_OUT_BEYOND],
          responseType: 'code'
        }
      },
    },
  },
})

more notes:

Expected behavior

Amplify.configure to work

Reproduction steps

  1. have amplify v3, no backend configuration or amplify-cli stuff, just manual Amplify.configure()
  2. migrate to v6 following Migrate from v5 to v6 documentation
  3. call Amplify.configure() at project root
  4. call signInWithRedirect() at a child component.

Code Snippet

No response

Log output

Error Stack trace
Uncaught (in promise) AuthUserPoolException: Auth UserPool not configured.
    at https://beyond.loggi.com/static/js/0.chunk.js:749809:13
    at assertTokenProviderConfig (https://beyond.loggi.com/static/js/0.chunk.js:751902:67)
    at _callee2$ (https://beyond.loggi.com/static/js/0.chunk.js:704125:51)
    at tryCatch (https://beyond.loggi.com/static/js/0.chunk.js:655040:17)
    at Generator.invoke [as _invoke] (https://beyond.loggi.com/static/js/0.chunk.js:655260:22)
    at prototype.<computed> [as next] (https://beyond.loggi.com/static/js/0.chunk.js:655093:21)
    at asyncGeneratorStep (https://beyond.loggi.com/static/js/0.chunk.js:491150:24)
    at _next (https://beyond.loggi.com/static/js/0.chunk.js:491172:9)
    at https://beyond.loggi.com/static/js/0.chunk.js:491179:7
    at new Promise (<anonymous>)
    at https://beyond.loggi.com/static/js/0.chunk.js:491168:12
    at _signInWithRedirect (https://beyond.loggi.com/static/js/0.chunk.js:704155:30)
    at signInWithRedirect (https://beyond.loggi.com/static/js/0.chunk.js:704112:30)
    at _callee5$ (https://beyond.loggi.com/static/js/main.chunk.js:148122:97)
    at tryCatch (https://beyond.loggi.com/static/js/0.chunk.js:655040:17)
    at Generator.invoke [as _invoke] (https://beyond.loggi.com/static/js/0.chunk.js:655260:22)
    at prototype.<computed> [as next] (https://beyond.loggi.com/static/js/0.chunk.js:655093:21)
    at asyncGeneratorStep (https://beyond.loggi.com/static/js/0.chunk.js:491485:24)
    at _next (https://beyond.loggi.com/static/js/0.chunk.js:491507:9)
    at https://beyond.loggi.com/static/js/0.chunk.js:491514:7
    at new Promise (<anonymous>)
    at https://beyond.loggi.com/static/js/0.chunk.js:491503:12
    at https://beyond.loggi.com/static/js/main.chunk.js:148136:21
    at federatedSignIn (https://beyond.loggi.com/static/js/main.chunk.js:156226:7)
    at handleFederatedSignIn (https://beyond.loggi.com/static/js/main.chunk.js:76006:12)
    at onClick (https://beyond.loggi.com/static/js/main.chunk.js:76159:14)
    at HTMLUnknownElement.callCallback (https://beyond.loggi.com/static/js/0.chunk.js:621670:18)
    at Object.invokeGuardedCallbackDev (https://beyond.loggi.com/static/js/0.chunk.js:621719:20)
    at invokeGuardedCallback (https://beyond.loggi.com/static/js/0.chunk.js:621779:35)
    at invokeGuardedCallbackAndCatchFirstError (https://beyond.loggi.com/static/js/0.chunk.js:621794:29)
    at executeDispatch (https://beyond.loggi.com/static/js/0.chunk.js:626029:7)
    at processDispatchQueueItemsInOrder (https://beyond.loggi.com/static/js/0.chunk.js:626061:11)
    at processDispatchQueue (https://beyond.loggi.com/static/js/0.chunk.js:626074:9)
    at dispatchEventsForPlugins (https://beyond.loggi.com/static/js/0.chunk.js:626085:7)
    at https://beyond.loggi.com/static/js/0.chunk.js:626296:16
    at batchedEventUpdates$1 (https://beyond.loggi.com/static/js/0.chunk.js:639983:16)
    at batchedEventUpdates (https://beyond.loggi.com/static/js/0.chunk.js:621468:16)
    at dispatchEventForPluginEventSystem (https://beyond.loggi.com/static/js/0.chunk.js:626295:7)
    at attemptToDispatchEvent (https://beyond.loggi.com/static/js/0.chunk.js:623778:7)
    at dispatchEvent (https://beyond.loggi.com/static/js/0.chunk.js:623696:23)
    at unstable_runWithPriority (https://beyond.loggi.com/static/js/0.chunk.js:656617:16)
    at runWithPriority$1 (https://beyond.loggi.com/static/js/0.chunk.js:629076:14)
    at discreteUpdates$1 (https://beyond.loggi.com/static/js/0.chunk.js:640000:18)
    at discreteUpdates (https://beyond.loggi.com/static/js/0.chunk.js:621480:16)
    at dispatchDiscreteEvent (https://beyond.loggi.com/static/js/0.chunk.js:623662:7)

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

@jgabriel98 jgabriel98 added the pending-triage Issue is pending triage label Apr 24, 2024
@jgabriel98
Copy link
Author

I've also tried to configure right before calling signInWithRedirect just to be sure:

Amplify.configure({
  Auth: {
    identityPoolId: process.env.REACT_APP_AWS_COGNITO_IDENT_POOL,
    region: process.env.REACT_APP_AWS_PROJECT_REGION,
    userPoolWebClientId: process.env.REACT_APP_AWS_WEB_CLIENT,
    mandatorySignIn: true,
  
    Cognito: {
      userPoolId: process.env.REACT_APP_AWS_USER_POOL_ID,
      userPoolClientId: process.env.REACT_APP_AWS_WEB_CLIENT,
      identityPoolId: process.env.REACT_APP_AWS_COGNITO_IDENT_POOL,
      signUpVerificationMethod: 'code',
      loginWith: {
        oauth: {
          domain: process.env.REACT_APP_AWS_COGNITO_DOMAINANME,
          scopes: ['phone', 'email', 'openid', 'profile', 'aws.cognito.signin.user.admin'],
          redirectSignIn: [process.env.REACT_APP_AWS_REDIRECT_SIGN_IN_BEYOND],
          redirectSignOut: [process.env.REACT_APP_AWS_REDIRECT_SIGN_OUT_BEYOND],
          responseType: 'code',
        }
      },
    },
  },
  })
await signInWithRedirect({ provider, customState })

still got same error.

@cwomack cwomack added the Auth Related to Auth components/category label Apr 24, 2024
@cwomack cwomack self-assigned this Apr 24, 2024
@jnixon2
Copy link

jnixon2 commented Apr 25, 2024

I also had this issue and after much debugging, it turned out to be an issue in my tsconfig.json.
It didnt seem to like:

"module": "commonjs"

Changing it to:

"module": "es2020"

fixed the issue

@jgabriel98
Copy link
Author

I also had this issue and after much debugging, it turned out to be an issue in my tsconfig.json. It didnt seem to like:

"module": "commonjs"

Changing it to:

"module": "es2020"

fixed the issue

Changed my jsconfig.json (i don't use ts) to:

{
"compilerOptions": { "baseUrl": "./src", "jsx": "react", "module": "ES2020" },
  "include": ["./src"],
  "exclude": ["node_modules", "**/node_modules/*", "build"],
  "typeAcquisition": { "include": ["jest"] }
}

No effect.

@cwomack
Copy link
Contributor

cwomack commented Apr 26, 2024

@jgabriel98, it looks like your Amplify.configure() may need a slight tweak. Can you see if removing some of the value just after Auth in it (like below) helps resolve the issue?

Amplify.configure({
  Auth: {
    Cognito: {
      userPoolId: process.env.REACT_APP_AWS_USER_POOL_ID,
      userPoolClientId: process.env.REACT_APP_AWS_WEB_CLIENT,
      identityPoolId: process.env.REACT_APP_AWS_COGNITO_IDENT_POOL,
      signUpVerificationMethod: 'code',
      loginWith: {
        oauth: {
          domain: process.env.REACT_APP_AWS_COGNITO_DOMAINANME,
          scopes: ['phone', 'email', 'openid', 'profile', 'aws.cognito.signin.user.admin'],
          redirectSignIn: [process.env.REACT_APP_AWS_REDIRECT_SIGN_IN_BEYOND],
          redirectSignOut: [process.env.REACT_APP_AWS_REDIRECT_SIGN_OUT_BEYOND],
          responseType: 'code'
        }
      },
    },
  },
})

@cwomack cwomack added question General question pending-response Issue is pending response from the issue requestor and removed pending-triage Issue is pending triage labels Apr 26, 2024
@jgabriel98
Copy link
Author

identityPoolId

Sure! @cwomack
done, no changes/same error 😞 .

FYI the resulting return value of Amplify.getConfig() after you suggestion was:

{
    "Auth": {
        "Cognito": {
            "userPoolId": "<REMOVED_FOR_SECURITY_REASONS>",
            "userPoolClientId": "<REMOVED_FOR_SECURITY_REASONS>",
            "identityPoolId": "us-east-1:<REMOVED_FOR_SECURITY_REASONS>",
            "signUpVerificationMethod": "code",
            "loginWith": {
                "oauth": {
                    "domain": "auth.one.loggi.com",
                    "scopes": [
                        "phone",
                        "email",
                        "openid",
                        "profile",
                        "aws.cognito.signin.user.admin"
                    ],
                    "redirectSignIn": [
                        "https://beyond.loggi.com/"
                    ],
                    "redirectSignOut": [
                        "https://beyond.loggi.com/"
                    ],
                    "responseType": "code"
                }
            }
        }
    }
}

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue requestor label Apr 26, 2024
@JustinHaut
Copy link

JustinHaut commented Apr 28, 2024

same issue after upgrading from v5 to v6..

[AuthUserPoolException: Auth UserPool not configured.]

Doesn't work even with the AWS generated amplifyconfiguration.json file either.

***interestingly, this is only an Expo 50 issue. Got the proper config and working v6 in Expo 49.

@JustinHaut
Copy link

@jgabriel98 Did you find a solution?

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 question General question
Projects
None yet
Development

No branches or pull requests

4 participants