Describe the bug
Fix #6811 has not fixed "No Auth module registered in Amplify" error
To Reproduce
Steps to reproduce the behavior:
node_modules folder and package-lock.json filenpm installnpm startExpected behavior
Data should be received from endpoints
Code Snippet
App.js
import React, { Component, lazy, Suspense } from 'react';
import './App.css';
import Amplify from 'aws-amplify';
import awsconfig from './aws-exports';
Amplify.configure(awsconfig);
...
.aws-exports.js
/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.
const awsmobile = {
"aws_project_region": "eu-west-1",
"aws_cognito_identity_pool_id": "eu-west-1:xxxx",
"aws_cognito_region": "eu-west-1",
"aws_user_pools_id": "eu-west-1_xxxx",
"aws_user_pools_web_client_id": "xxxx",
"oauth": {},
"aws_appsync_graphqlEndpoint": "https://xxxx.appsync-api.eu-west-1.amazonaws.com/graphql",
"aws_appsync_region": "eu-west-1",
"aws_appsync_authenticationType": "AMAZON_COGNITO_USER_POOLS"
};
export default awsmobile;
SignIn Function
import { Auth } from 'aws-amplify';
export default function (payload) {
return Auth.signIn(payload.inputUsername.toLowerCase(), payload.inputPassword);
}
getProjects.js (API call once logged in to populate home page)
import { API, graphqlOperation } from 'aws-amplify';
import * as Queries from '../../graphql/custom-queries';
export default function(username) {
const query = {
cognitoID: username
}
return API.graphql(graphqlOperation(Queries.getProjectsForHomePage, query));
}
custom-queries.js
export const getProjectsForHomePage = /* GraphQL */ `
query GetProjectsForHomePage($cognitoID: String!) {
userByCognitoID(cognitoID: $cognitoID) {
items {
projects {
items {
project {
id
projectName
projectDescription
projectStatus
projectAvatar
createdAt
teamMembers {
items {
isAdministrator
attendee {
id
accreditations {
items {
expiryDate
}
}
}
}
}
}
}
}
}
}
}
`;
package.json
"dependencies": {
"@aws-amplify/auth": "^3.4.4",
"@aws-amplify/core": "^3.5.4",
"@aws-amplify/pubsub": "^2.1.9",
"aws-amplify": "^3.3.1",
"aws-amplify-react": "^4.2.5",
...
},
Screenshots
Console before user logs in
Image
Console after user logs in and API calls are made
Image
What is Configured?
Configured Amplify Parts
All configured through Amplify CLI
Additional context
The problem occurred after reinstalling node_modules folder. I have another Mac that has the same project installed and that is still working after pulling the latest commit from Git.
@aws-amplify/api: v3.2.4
@aws-amplify/api-graphql: v1.2.4
@aws-amplify/auth: v3.4.4
@aws-amplify/core: v3.5.4
Yep, nothing changed - i am also still getting the error: 'GraphQLAPI - ensure credentials error No Auth module registered in Amplify'
However when running locally in my Ionic project it works fine, but on an IOS device it doesnt!
Thanks for reporting this @benjeater, we will be digging into this today and providing an update as soon as we can
@sammartinez this issue is framework agnostic, React label is not needed. I've reproduced it in Angular project.
By not including @aws-ampify/core package directly as a dependency, the last version is pulled as indirect dependency by @aws-ampify/auth. After rebuilding the project last week we started to have problems with the app not loading, we've spent long hours on this issue so far.
It's great you are working on this :+1:
I am having a similar issue in a React app.
We use Amplify, but with Cognito Userpool and Identity pool. I have created an UnAuth role and I want to run a couple of queryies via @AWS_IAM. These are unauth queries.
I tried using
api.graphql({
query,
variables,
authMode: GRAPHQL_AUTH_MODE.AWS_IAM
});
which results in Error: No credentials.
Then when I define a new AWSAppSyncClient with
auth: {
type: AUTH_TYPE.AWS_IAM,
credentials: () => Auth.currentCredentials(),
},
I am getting the No Auth module registered error.
But in the app.ts I see:
API.configure(awsConfig)
Auth.configure(awsConfig)
Storage.configure(awsConfig)
so not really sure what is wrong.
Using Amplify 3.2.0
FIX*
okay moving away from AUTH imported from 'aws-amplify' to Auth imported from '@aws-amplify/auth'; fixed the issue.
I find this pretty confusing.
@mattiLeBlanc Are you experiencing the same issue with [email protected] (which is latest)?
We just pushed out a couple of fixes and I wasn't able to reproduce with my app using Auth, API, & Storage.
The one difference is that I'm doing import { Amplify, API, Auth, Storage } from "aws-amplify" and Amplify.configure(awsExports) to ensure all packages are up-to-date.
This is a high-priority bug for us, so I'm testing vanilla, Angular, CRA, & Next.js apps to try & determine the root cause.
@ericclemmons I can confirm the bug is gone after updating amplify libraries. I'm using modular approach and that core package version fixes the problem: @aws-amplify/core": "3.5.5".
Thanks a lot :1st_place_medal:
@mordka Thanks for the update! @benjeater Can you confirm it's fixed with yesterday's release as well?
I want to make sure nothing's amiss between yours & @mordka's experience 馃檹
Thanks guys.
@ericclemmons I uninstalled all aws-amplify packages and reinstalled. Everything is working again. Thanks to everyone who contributed to this fix.
I got this error again when I build my NextJS project and exported the static code.
Running NEXT in development mode, I worked fine, but after exporting it and running that in a webserver, I got the No Auth module registered in Amplify error.
Upgrading my Core and AUTH package did resolve the issue.
So I am getting another error: GraphQLAPI - ensure credentials error No Cognito Identity pool provided for unauthenticated access when I use import { GraphQLAPI } from '@aws-amplify/api-graphql' instead of import API from '@aws-amplify/api'.
In the NEXT app I do GraphQLAPI.configure(awsConfig) and then I use the GraphQLAPIClass for typing in my API facade.
instead of the deprecated APIClass. But when I do use the GrahpQlAPI and GraphQLAPIClass the configure doesn't seem to work.
Running "@aws-amplify/api": "version": "3.2.5 and "@aws-amplify/core" : "version": "3.5.5
@mattiLeBlanc Is your usage of GraphQLAPI in your Next.js apps' server-side code or your client-side code?
Can you open a new issue with these details, sample code, etc. so we can look into it?