Closed abhjaw closed 4 years ago
my sympathies for this issue.
i dont know the codebase well so i took a look. this is the only place this error occurs: https://github.com/aws-amplify/amplify-js/blob/1cb1afd1e56135908dceb2ef6403f0b3e78067fe/packages/core/src/Credentials.ts#L108-L112
therefore it probably is that Amplify.Auth
is falsy. based on this comment, Auth
has to be imported: https://github.com/aws-amplify/amplify-js/blob/1cb1afd1e56135908dceb2ef6403f0b3e78067fe/packages/core/src/Credentials.ts#L36
I observe that Amplify Auth relies on a curious antipattern of registering as a side effect: https://github.com/aws-amplify/amplify-js/blob/1cb1afd1e56135908dceb2ef6403f0b3e78067fe/packages/auth/src/Auth.ts#L2087
as a first check - have you cleaned up your imports somehow since you ran this code without issue (some automated tooling cleans unused imports, which is a problem if importing has side effects)? do you still import Amplify, { Auth } from 'aws-amplify';
?
if you are satisfied that those things have not changed - is there caching or some other race condition going on that caused your unchanged code to now stop working - and if so, can you clear all sources of cache to verify this?
@abhjaw are you running Amplify on a node environment or this runs on a browser?
@abhjaw are you running Amplify on a node environment or this runs on a browser?
I am using Cloud9 IDE and I am using the preview browser in Cloud9.
my sympathies for this issue. Thank you :)
as a first check - have you cleaned up your imports somehow since you ran this code without issue (some automated tooling cleans unused imports, which is a problem if importing has side effects)? do you still
import Amplify, { Auth } from 'aws-amplify';
?My imports statements are the same: import React from "react"; import Button from 'react-bootstrap/Button'; import Search from "./search/Search"; import { indexId, region } from "./services/Kendra"; import { facetConfiguration } from "./search/configuration"; import S3 from 'aws-sdk/clients/s3'; import AWS from 'aws-sdk'; import aws_exports from './aws-exports'; import Kendra from 'aws-sdk/clients/kendra'; import {Auth} from '@aws-amplify/auth'; import { AmplifyGreetings, AmplifyAuthenticator } from '@aws-amplify/ui-react'; import { AuthState } from '@aws-amplify/ui-components';
import "./App.css";
if you are satisfied that those things have not changed - is there caching or some other race condition going on that caused your unchanged code to now stop working - and if so, can you clear all sources of cache to verify this?
I cleared the browser cache but still had the same issue. Also tried in a different browser (Firefox instead of Chrome). But it is still having the same problem.
@abhjaw you are using modular imports there: https://docs.amplify.aws/lib/auth/advanced/q/platform/js#using-modular-imports
did you run Auth.configure();
?
notice the difference between @aws-amplify/auth
and aws-amplify
@abhjaw you are using modular imports there: https://docs.amplify.aws/lib/auth/advanced/q/platform/js#using-modular-imports
did you run
Auth.configure();
?notice the difference between
@aws-amplify/auth
andaws-amplify
Yes, I am doing Auth.configure(aws_exports);
I just changed Auth.currentCredentials() to Augh.currentUserCredentials() and the thing started working.
I ran into a similar issue when trying to update pinpoint endpoints, so instead of calling configure for the individual packages, called configure from the core package and it solved the problem.
import Auth from "@aws-amplify/auth";
import Storage from "@aws-amplify/storage";
import API from "@aws-amplify/api";
import Analytics from "@aws-amplify/analytics";
+ import Amplify from "@aws-amplify/core";
Amplify.Logger.LOG_LEVEL = "VERBOSE";
+ Amplify.configure(Config);
- Auth.configure(Config.Auth);
- Storage.configure(Config.Storage);
- API.configure(Config.API);
- Analytics.configure(Config.Analytics);
Same issue here, but I don't have unauthenticated users enabled.
In my nuxt
project:
plugins/aws-amplify.client.js
import Auth from '@aws-amplify/auth'
import awsConfig from '@/config/aws-config'
export default async ({ store, $axios }) => {
Auth.configure(awsConfig)
I had to downgrade dependencies to work again.
package.json
"dependencies": {
"@aws-amplify/auth": "~3.3.0",
},
"resolutions": {
"@aws-amplify/core": "~3.4.0"
}
What | Bad | Good |
---|---|---|
@aws-amplify/auth |
3.4.1 | 3.3.6 |
@aws-amplify/core |
3.5.1 | 3.4.7 |
I suspect the problem lies more in @aws-amplify/core
, but I downgraded both to be safe.
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help
channels or Discussions for those types of questions.
Describe the bug Auth.currentCredentials() fails with exception "No Auth module registered in Amplify". The same code was working a couple of weeks back (in fact I have it working in a Cloud9 environment). Any new installs however are not working for this code.
To Reproduce Steps to reproduce the behavior:
Expected behavior Get either unauth or authenticated credentials as the case may be. Use these credentials to call STS assume role with the right permissions to access Amazon Kendra index, S3 objects etc. Code Snippet This code snippet has stopped working
This code snippet continues to work
aws_exports.js
admin:~/environment/kendra-poc (master) $ npx envinfo --system --binaries --browsers --npmPackages --npmGlobalPackages npx: installed 1 in 1.805s
System: OS: Linux 4.14 Amazon Linux AMI 2018.03 CPU: (2) x64 Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz Memory: 1.66 GB / 3.85 GB Container: Yes Shell: 4.2.46 - /bin/bash Binaries: Node: 10.22.0 - ~/.nvm/versions/node/v10.22.0/bin/node npm: 6.14.6 - ~/.nvm/versions/node/v10.22.0/bin/npm npmPackages: @aws-amplify/cli: ^4.29.0 => 4.29.0 @aws-amplify/ui-react: ^0.2.18 => 0.2.18 @testing-library/jest-dom: ^4.2.4 => 4.2.4 @testing-library/react: ^9.5.0 => 9.5.0 @testing-library/user-event: ^7.2.1 => 7.2.1 @types/jest: ^24.9.1 => 24.9.1 @types/lodash: ^4.14.161 => 4.14.161 @types/node: ^12.12.55 => 12.12.55 @types/rc-slider: ^8.6.6 => 8.6.6 @types/react: ^16.9.49 => 16.9.49 @types/react-dom: ^16.9.8 => 16.9.8 aws-amplify: ^3.1.1 => 3.1.1 aws-sdk: ^2.747.0 => 2.747.0 bootstrap: ^4.5.2 => 4.5.2 moment: ^2.27.0 => 2.27.0 node-sass: ^4.14.1 => 4.14.1 rc-slider: ^9.2.4 => 9.2.4 react: ^16.13.1 => 16.13.1 react-bootstrap: ^1.3.0 => 1.3.0 react-dom: ^16.13.1 => 16.13.1 react-google-charts: ^3.0.15 => 3.0.15 react-scripts: 3.4.3 => 3.4.3 semantic-ui-react: ^1.2.1 => 1.2.1 typescript: ^3.9.7 => 3.9.7 npmGlobalPackages: @aws-amplify/cli: 4.29.0 @aws-amplify/ui-react: 0.2.15 @types/lodash: 4.14.161 @types/rc-slider: 8.6.6 aws-amplify: 3.0.24 aws-sdk: 2.739.0 bootstrap: 4.5.2 cdk: 1.61.0 coffeescript: 2.5.1 esformatter: 0.11.3 js-beautify: 1.13.0 moment: 2.27.0 node-sass: 4.14.1 npm: 6.14.6 prettier: 2.1.1 rc-slider: 9.2.4 react-bootstrap: 1.3.0 react-google-charts: 3.0.15 semantic-ui-react: 1.2.1 typescript: 4.0.2