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

No Auth module registered in Amplify after Fix #6811 #6836

Closed
benjeater opened this issue Sep 20, 2020 · 14 comments
Closed

No Auth module registered in Amplify after Fix #6811 #6836

benjeater opened this issue Sep 20, 2020 · 14 comments
Assignees
Labels
Auth Related to Auth components/category React React related issues to-be-reproduced Used in order for Amplify to reproduce said issue

Comments

@benjeater
Copy link

Describe the bug
Fix #6811 has not fixed "No Auth module registered in Amplify" error

To Reproduce
Steps to reproduce the behavior:

  1. Deleted node_modules folder and package-lock.json file
  2. Ran npm install
  3. Ran npm start
  4. No data received from GraphQL endpoints and error in console

Expected 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

  • Auth
  • API
  • Functions x 4

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
@benjeater benjeater added the to-be-reproduced Used in order for Amplify to reproduce said issue label Sep 20, 2020
@oliverandersencox
Copy link

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!

@sammartinez sammartinez added Auth Related to Auth components/category React React related issues labels Sep 21, 2020
@sammartinez
Copy link
Contributor

Thanks for reporting this @benjeater, we will be digging into this today and providing an update as soon as we can

@mordka
Copy link
Contributor

mordka commented Sep 22, 2020

@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 👍

@mattiLeBlanc
Copy link

mattiLeBlanc commented Sep 23, 2020

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.

@ericclemmons
Copy link
Contributor

@mattiLeBlanc Are you experiencing the same issue with aws-amplify@3.3.2 (which is latest)?

https://www.npmjs.com/package/aws-amplify/v/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.

@mordka
Copy link
Contributor

mordka commented Sep 25, 2020

@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 🥇

@ericclemmons
Copy link
Contributor

@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 🙏

@mattiLeBlanc
Copy link

Thanks guys.

@benjeater
Copy link
Author

@ericclemmons I uninstalled all aws-amplify packages and reinstalled. Everything is working again. Thanks to everyone who contributed to this fix.

@mattiLeBlanc
Copy link

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.

@mattiLeBlanc
Copy link

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

@ericclemmons
Copy link
Contributor

@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?

@DmitriWolf
Copy link

My fix also involved updating packages. In package.json what was this:

    "aws-amplify": "^3.0.7",
    "aws-amplify-react": "^4.2.22",

updated to:

    "amplify": "0.0.11",
    "aws-amplify": "^3.3.18",
    "aws-amplify-react": "^4.2.22",

When I did npm update aws-amplify it added the amplify package. The aws-amplify-react I updated by hand after finding the latest version with npm outdated.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Auth Related to Auth components/category React React related issues to-be-reproduced Used in order for Amplify to reproduce said issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants