Closed pablovargasosorio closed 10 months ago
Downgrade @aws-amplify/auth
and @aws-amplify/core
to 6.0.2
I had the same problem when I upgraded @aws-amplify/auth from v6.0.2 to v6.0.5. It worked again when I downgraded to v6.0.2, but I had to downgrade @aws-amplify/core as well.
Unfortunately v6.0.2 is not working to me neither :(
Have you downgraded both dependencies?
Yeah, and I made sure that's the version installed in both auth/core, no luck, same error...
Hi @pablovargasosorio thanks for opening this issue. Quick question, are you calling signInWithRedirect()
on the same path as your redirectSignIn? If not can you try importing signInWIthRedirect
on the same path?
HI @nadetastic - I can confirm I've just run in to this issue as well.
I won't have time until tomorrow to provide more details, but in case helpful, it's worth mentioning that it occurred when attempting to configure the cognitoUserPoolsTokenProvider
and when I removed any references to it, everything worked as expected.
@dkhuntrods thank you for the context, can you share the code of how you have implemented your TokenProvider?
Hi @pablovargasosorio thanks for opening this issue. Quick question, are you calling
signInWithRedirect()
on the same path as your redirectSignIn? If not can you try importingsignInWIthRedirect
on the same path?
@nadetastic The reloc path is a 'virtual' route with no components, but I tried to just importing the sign-in method in the same place I do the Amplify.configure, but I it doesn't fix it.
@pablovargasosorio can you confirm that you installed @aws-amplify/auth
into your project? If so the recommendation is to install aws-amplify
package instead and import from it. @aws-amplify/auth
is marked for internal use only.
For example
import { Amplify } from 'aws-amplify'
import { signInWithRedirect } from 'aws-amplify/auth' // not '@aws-amplify/auth'
import { Hub } from 'aws-amplify/utils'
For me this error happen during signOut. So I just downgrade to "aws-amplify": "^6.0.2" as mention by @rkstgr.
In the code I import like this as mention by @nadetastic
import { Hub } from 'aws-amplify/utils';
import { signOut, fetchAuthSession } from 'aws-amplify/auth';
Now it working.
Thank @rkstgr @nadetastic.
@pablovargasosorio can you confirm that you installed
@aws-amplify/auth
into your project? If so the recommendation is to installaws-amplify
package instead and import from it.@aws-amplify/auth
is marked for internal use only.For example
import { Amplify } from 'aws-amplify' import { signInWithRedirect } from 'aws-amplify/auth' // not '@aws-amplify/auth' import { Hub } from 'aws-amplify/utils'
@nadetastic That was the reason of the issue. I changed my package.json
FROM:
"@aws-amplify/auth": "6.0.2"
TO:
"aws-amplify": "6.0.2",
Also changed my imports to use from 'aws-amplify/auth', instead of '@aws-amplify/auth' and login works Thank you very much!
I strongly recommend to improve the changelog documentation to let us know the '@' notation is deprecated in V6... Thanks again!
Glad to have gotten your issues resolved!
@pablovargasosorio thank you for the feedback! We are working to make improvements in the migration guide 🙂
@nadetastic I'm having a similar problem. I'm on version 6.0.2 defined in my package.json as "aws-amplify": "6.0.2". The configure method runs, but when I attempt to sign in, I get this error: error signing in AuthUserPoolException: Auth UserPool not configured. I have checked the userPoolId, userClientPoolId and identityPoolId, which all exist in Cognito.
The error seems be happening when calling Amplify.getConfig() in the signInWithSRP function. authConfig is undefined.
Here's my stack trace and code below. Is there something I'm missing?
error signing in AuthUserPoolException: Auth UserPool not configured.
at http://localhost:3000/@fs/Users/jdog/Projects/The%20Gap%20App/node_modules/.vite/deps/chunk-PE4GYZUI.js?v=fdd028b4:201:11
at assertTokenProviderConfig (http://localhost:3000/@fs/Users/jdog/Projects/The%20Gap%20App/node_modules/.vite/deps/chunk-PE4GYZUI.js?v=fdd028b4:404:10)
at signInWithSRP (http://localhost:3000/@fs/Users/jdog/Projects/The%20Gap%20App/node_modules/.vite/deps/chunk-BG77EEEK.js?v=fdd028b4:6163:3)
at signIn (http://localhost:3000/@fs/Users/jdog/Projects/The%20Gap%20App/node_modules/.vite/deps/chunk-BG77EEEK.js?v=fdd028b4:6275:14)
at async signIn (http://localhost:3000/src/auth/sign-in/AuthSignInStore.tsx:34:11)
import { signUp, confirmSignUp, signIn, signOut, getCurrentUser, fetchAuthSession, fetchUserAttributes, fetchMFAPreference } from 'aws-amplify/auth'
import { Amplify } from 'aws-amplify'
export default class AuthStore {
// ...
static configure() {
Amplify.configure({
Auth: {
Cognito: {
userPoolId: variables.userPoolId,
userPoolClientId: variables.userPoolWebClientId,
identityPoolId: variables.identityPoolId,
loginWith: {
oauth: {
domain: variables.userPoolDomain,
scopes: notNull(variables.cognitoOauthScopes) as OAuthScope[],
redirectSignIn: [variables.appHost],
redirectSignOut: [variables.appHost],
responseType: 'code',
},
},
}
},
API: {
REST: {
[variables.amplifyApiName]: {
endpoint: import.meta.env.VITE_API_URL,
region: import.meta.env.VITE_REGION,
}
}
}
})
}
signIn = async () => {
try {
const { isSignedIn, nextStep } = await signIn({
username: this.fields.email,
password: this.fields.password,
})
console.log(isSignedIn, nextStep)
} catch (error) {
console.log('error signing in', error)
}
}
}
Hi @InspiredJason can you provide a bit more context on you app? What framework is it (Angular for ex)? And an example of how you are using the AuthStore.signIn()
you have defined above?
Hi @nadetastic - thanks for the reply. We're using SST as our serverless framework including a React frontend. Below is an extract of the signin component along. Essentially, just a react component, which configures Amplify, then a call to our sign in function shown in my message above in our AuthStore class. I've also included the result of a call to Amplify.getConfig() after calling configure(). Anything stick out to you?
import { observer } from 'mobx-react-lite'
import { useAuthStore } from '../AuthStore'
import onEnterProp from 'reusable/utils/on-enter-prop'
import ButtonWithProgress from 'reusable/mui/progress-button/ButtonWithProgress'
import TextFieldPassword from 'reusable/mui/text-field-password/TextFieldPassword'
import Box from '@mui/material/Box'
import useStore from 'reusable/mobx-store-utils'
export default observer(function AuthSignIn() {
const authStore = useAuthStore()
const formHandler = authStore.formHandler
// just a useEffect hook with empty param list
useInitialMount(() => {
AuthStore.configure()
})
return (
<>
<Box>
{formHandler.email.bindInput(ip =>
<TextField
autoFocus
fullWidth
label="Email"
name="email"
{...onEnterProp(authStore.signIn)}
{...ip}
/>)}
</Box>
<Box>
{formHandler.password.bindInput(ip =>
<TextFieldPassword
name="password"
fullWidth
label="Password"
{...onEnterProp(authStore.signIn)}
{...ip}
/>)}
</Box>
<ButtonWithProgress
loading={authStore.loader.isLoading}
variant="contained"
onClick={authStore.signIn}>
Sign in
</ButtonWithProgress>
</>
)
})```
Can confirm removing individual @aws-amplify packages for each module and using just ONE package: aws-amplify
solves this problem.
@mnovati Thanks for your reply. I can confirm I have it working. I didn't have any @amplify references in my package.json file. But I did go ahead and delete my node_modules folder and install amplify 6.0.5. Perhaps @amplify references were still kicking about in my node_modules? @nadetastic thanks for investigating - happy to have this sorted.
I hope I'm on time to the party... it's not working!
Upd: never mind... was trying to call fetchAuthSession() on public page
I can't figure out what's causing it, custom and default configs have the same effect. This happens on main public page, there is no authentication.
'use client';
import { Amplify } from 'aws-amplify';
import config from '../../amplifyconfiguration.json';
import { ResourcesConfig } from '@aws-amplify/core';
const [localRedirectSignIn, productionRedirectSignIn] = config.oauth.redirectSignIn.split(',');
const [localRedirectSignOut, productionRedirectSignOut] = config.oauth.redirectSignOut.split(',');
if (typeof window !== 'undefined') {
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/),
);
const updatedAwsConfig: ResourcesConfig = {
...config,
Auth: {
Cognito: {
userPoolClientId: config.aws_user_pools_id,
userPoolId: config.aws_user_pools_id,
loginWith: {
oauth: {
...config.oauth,
domain: config.oauth.domain,
scopes: config.oauth.scope,
responseType: config.oauth.responseType as 'code' | 'token',
redirectSignIn: [isLocalhost ? localRedirectSignIn : productionRedirectSignIn],
redirectSignOut: [isLocalhost ? localRedirectSignOut : productionRedirectSignOut],
},
},
},
},
};
Amplify.configure(updatedAwsConfig);
console.log('Amplify done initial configuration')
}
export default function ConfigureAmplifyClientSide() {
return null;
}
Deps
"@aws-amplify/api@6.0.6",
"@aws-amplify/ui-react@^6.0.4",
"aws-amplify@6.0.6",
Hi @OperationalFallacy, just to confirm, is this an issue for you?
Hi @OperationalFallacy, just to confirm, is this an issue for you?
It's not an issue, everything is working as expected. I was incorrectly calling fetchAuthSession() on the publicly accessible page, hence it was erroring out.
Ok glad to hear that 😄, I'll go ahead and resolve this issue. Thank you!
Getting same error on "aws-amplify": "^6.0.6"
Amplify.configure({
Auth: {
mandatorySignIn: false,
region: config.cognito.REGION,
userPoolId: config.cognito.USER_POOL_ID,
identityPoolId: config.cognito.IDENTITY_POOL_ID,
userPoolWebClientId: config.cognito.APP_CLIENT_ID
},
API: {...
I have reviewed all of the documentation and migration guide and nothing seems out of whack. Help please...
@willjstevens with amplify 6, some of those things need to go under Auth: { Cognito : {} } instead otop level Auth. I don't remember which ones but check the spec!
I got it working with a hybrid:
Auth: {
identityPoolId: config.cognito.IDENTITY_POOL_ID,
region: config.cognito.REGION,
userPoolWebClientId: config.cognito.APP_CLIENT_ID,
mandatorySignIn: false,
Cognito: {
userPoolId: config.cognito.USER_POOL_ID,
userPoolClientId: config.cognito.APP_CLIENT_ID
}...
I used documentation from the API section blended with the Auth section. All of the Auth options should be under the Auth section in the documentation. And more formally documented with all potential options than just an example.
I have same problem
"vue": "^3.3.4",
"aws-amplify": "6.0.2", (and 6.0.6 still not working like 6.0.2)
and here console.log
Look at the config structure here. https://github.com/aws-amplify/amplify-js/issues/12627#issuecomment-1848214340
https://github.com/aws-amplify/amplify-js/issues/12627#issuecomment-1848214340
Thanks for this it worked for me aswell. I think the documentation needs to update to account for adding those under Auth
as well as Cognito
.
@tkalra Glad that you were able to get working. Could you let me know where you see the documenation needing an update? For reference, the expected configuration is documented here - https://docs.amplify.aws/react/tools/libraries/configure-categories/#authentication-amazon-cognito
cc @willjstevens
@nadetastic to clarify, things are a bit unclear. A few points:
Thanks for checking and helping improve things.
@willjstevens thanks for the feedback and context! Let me clarify a bit:
The first and second links in item 1, is the proper way to set up the resources, however it doesn't clearly show identityPoolId
configuration. The third link in item 1 and first link in item 2(link) is a reference to how config would be done previous versions on amplify (v5 and before, the switch under "Choose your framework/language" on the top left)
I'm working to clarify the documentation in Configure Amplify categories (item 1 links) to clearly show how to configure identityPoolId and a few more options 😃
The config here is not valid according to the typescript types in 6.0.2
Just adding this for reference if others see this because seems like a lot of activity on the thread, This is not related to the config questions, but if you have the problem AuthUserPoolException: Auth UserPool not configured.
If you were using @aws-amplify
dependencies before, use the aws-amplify
single import instead for 6.0.2+
BEFORE
AFTER
I'm still having he same issue after trying everything else mentioned in this thread and anywhere else. It is a vue/vite app with pnpm. package.json
"dependencies": {
"aws-amplify": "6.0.9",
"@aws-amplify/pubsub": "6.0.9",
...
main.ts
import type { ResourcesConfig } from "aws-amplify";
import { Amplify } from "aws-amplify";
import { getCurrentUser } from "aws-amplify/auth";
const config: ResourcesConfig = {
Auth: {
Cognito: {
// REQUIRED - Amazon Cognito Identity Pool ID
identityPoolId: "___",
// OPTIONAL - Amazon Cognito User Pool ID
userPoolId: "___",
// OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string)
userPoolClientId: "___",
},
},
};
Amplify.configure(awsExports);
console.log(Amplify.getConfig());
const authUser = await getCurrentUser(); // This is the line that causes the error
It console logs the proper config then throws an error when calling the getCurrentUser function. Looking in the debugger it seems like the Amplify class that the function is importing from @aws-amplify/core is not the same instance as the one I import from aws-amplify.
I'm still facing with this issue
"aws-amplify": "^6.0.10",
err AuthUserPoolException: Auth UserPool not configured.
at http://localhost:8081/node_modules/.vite/deps/chunk-PZK3XFUA.js?v=5a19cc1b:42:11
at assertTokenProviderConfig (http://localhost:8081/node_modules/.vite/deps/chunk-PZK3XFUA.js?v=5a19cc1b:164:10)
at signInWithSRP (http://localhost:8081/node_modules/.vite/deps/chunk-PZK3XFUA.js?v=5a19cc1b:10090:3)
at signIn (http://localhost:8081/node_modules/.vite/deps/chunk-PZK3XFUA.js?v=5a19cc1b:10203:14)
at async logIn (http://localhost:8081/src/views/SignIn.vue:53:9)
SignIn.vue: Auth UserPool not configured. err
And Amplify.getConfig() only return empty object @nadetastic
@natuan62 For me I had to use Amplify.configure() in both a server component and a client component. I'm using Next.js so I put it into my Amplify context file in the initialization process.
Just adding this for reference if others see this because seems like a lot of activity on the thread, This is not related to the config questions, but if you have the problem
AuthUserPoolException: Auth UserPool not configured.
If you were using
@aws-amplify
dependencies before, use theaws-amplify
single import instead for 6.0.2+BEFORE
AFTER
I can confirm this 👍 After removing our used category @aws-amplify/auth
and only using aws-amplify
it worked for me.
They also described the "old" @aws-amplify/auth
package as INTERNAL USE ONLY
:
https://www.npmjs.com/package/@aws-amplify/auth
So, since v6 you need to install the whole "aws-amplify" package. But you can still import from "aws-amplify/auth"
I can confirm this 👍 After removing our used category
@aws-amplify/auth
and only usingaws-amplify
it worked for me. They also described the "old"@aws-amplify/auth
package asINTERNAL USE ONLY
: https://www.npmjs.com/package/@aws-amplify/authSo, since v6 you need to install the whole "aws-amplify" package. But you can still import from "aws-amplify/auth"
I have done that but am still having the same issue
For those still struggling here, it took me a while but I was able to get everything working. I put together a simple demo stripped from my production app. The demo is not functional but it shows the exact amplify configuration, locked package versions for amplify and nextjs as well as both server and client Amplify.configure implementations. If it is not clear or if it would be beneficial for me to complete the demo to make it run, please lmk.
In my case, the version inconsistency prevented the signOut from working.
"dependencies": {
"@aws-amplify/auth": "^6.0.13",
"@aws-amplify/core": "^6.0.13",
- "aws-amplify": "^6.0.10"
+ "aws-amplify": "^6.0.13"
}
Upgrading "aws-amplify" fixed the problem.
For those whom added manual config like me, extend your config with type ResourcesConfig
coming from aws-amplify
. This help me fix the above issue.
I still have this issue and cannot figure out how to fix it... using "aws-amplify": "^6.0.28"
no matter how I get the Auth not configured error :(
Same situation of @made2591, also with version 6.0.28, using js (not ts), migration from amplify v3 to amplify v6
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'
}
},
},
},
})
@jgabriel98 I found the cause of my issue. You should be sure 100% you configure amplify - eventually I did it a couple of times - before calling the API (even only to test it, try to call it just before the get or post or whatever call). Just a suggestion, with the other version of amplify same code it wasn't necessary!
@jgabriel98 I found the cause of my issue. You should be sure 100% you configure amplify - eventually I did it a couple of times - before calling the API (even only to test it, try to call it just before the get or post or whatever call). Just a suggestion, with the other version of amplify same code it wasn't necessary!
@made2591 i`ll try, thanks.
@made2591 i ran this exact code, and still got the same error
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 })
I upgraded from v5 and I'm getting the same error from the promise rejection, but interestingly in error.message it gives [UserAlreadyAuthenticatedException: There is already a signed in user.]
For future reference, here it is the configuration template:
Hi everyone
I got the same error
As previous comments said :
{
Auth: {
Cognito: {
userPoolClientId: "xxxxx",
userPoolId: "xxxxx",
identityPoolId: "xxxxx",
signUpVerificationMethod: "code",
loginWith: {
// Optional
oauth: {
domain: "xxxxx",
scopes: ["email", "openid", "profile", "aws.cognito.signin.user.admin"],
redirectSignIn: ["http://localhost:3000/"],
redirectSignOut: ["http://localhost:3000/"],
responseType: "code"
},
username: "true",
email: "false", // Optional
phone: "false" // Optional
}
}
}
};```
and it worked
thanks to everyone 💯
For reference, I found another undocumented option allowGuestAccess
, it is hidden here
Amplify.configure({
Auth: {
Cognito: {
...
allowGuestAccess: true|false
...
}
}
});
Before opening, please confirm:
JavaScript Framework
Angular
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
After upgrading to aws-amplify/auth v6 I'm unable to login, due to the UserPool configuration:
I'm able to start the login flow (user selection, credentials form, etc.) but when relocation happens to /reloc?code=...... in my homepage, then it fails. That means the user pool is properly setup from my login page (if not, I couldn't authenticate at all. My login page is running Amplify.configure successfully)
It seems like part of the Amplify framework is not initialized. The exception is provoked by someone who is calling to this assertion function with an empty cognitoConfig (In my config JSON passed to Amplify.configure I do have values for userPoolId and userPoolClientId):
Expected behavior
Successful login
Reproduction steps
Code Snippet
This is my configure call passing the JSON with the user pool:
These are my functions to login (google/microsoft):
Log output
aws-exports.js
No response
Manual configuration
Also tried passing the new model (even though the legacy one above should be converted by the library and works properly)
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
Perhaps the 'configure' call is not fully configuring the Amplify framework. Notice how the DEBUG output is much more complete in v5 in the login page. This is before I try to login, so before I get the UserPool exception or any other error in the browser console.
Login page. DEBUG output in v5.6.5:
Login page. DEBUG output in v6.0.5: