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

Amplify prints out AuthError when NOT having Auth component #9771

Closed
3 tasks done
jamesaucode opened this issue Apr 5, 2022 · 6 comments · Fixed by #10090
Closed
3 tasks done

Amplify prints out AuthError when NOT having Auth component #9771

jamesaucode opened this issue Apr 5, 2022 · 6 comments · Fixed by #10090
Assignees
Labels
Auth Related to Auth components/category bug Something isn't working Core Related to core Amplify issues

Comments

@jamesaucode
Copy link
Contributor

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

REST API

Amplify Categories

auth, api

Environment information

# Put output below this line


Describe the bug

Amplify JS version: "aws-amplify": "^4.3.17",

When setting up a Amplify React app WITHOUT Auth component, calling the API.get will print out the below error in browser console

[ERROR] 00:14.198 AuthError - 
            Error: Amplify has not been configured correctly. 
            The configuration object is missing required auth properties.
            This error is typically caused by one of the following scenarios:

            1. Did you run `amplify push` after adding auth via `amplify add auth`?
                See https://aws-amplify.github.io/docs/js/authentication#amplify-project-setup for more information

            2. This could also be caused by multiple conflicting versions of amplify packages, see (https://docs.amplify.aws/lib/troubleshooting/upgrading/q/platform/js) for help upgrading Amplify packages.

Expected behavior

It should not print error in the browser console

Reproduction steps

  • set up a basic React app
  • set up a public accessible API GW
  • Use the following code snippet to call REST API
import Amplify, { API } from 'aws-amplify';
Amplify.configure({
  API: {
    endpoints: [
      {
        name: "rest",
        endpoint: "<API endpoint>" 
      }
    ]
  }
});

function App() {

  API.get('rest', '/items')

  return (
    <div className="App">
     
    </div>
  );
}

export default App;

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


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

@jamesaucode jamesaucode added bug Something isn't working Auth Related to Auth components/category API Related to REST API issues labels Apr 5, 2022
@alharris-at
Copy link

@jamesaucode, could you provide your package.json file to help in repro and resolution? As noted in the error, we've seen this happen from time to time when there are duplicate version of the amplify-js lib, or amplify-js alongside the amplify-datastore imports.

@RMG0
Copy link

RMG0 commented Apr 12, 2022

Similar issue for me with react-native app. I am using
"@aws-amplify/pushnotification": "^4.3.16",
"aws-amplify": "^4.3.19",
and not even using auth in my app. still its throwing this same error

@stocaaro stocaaro removed the p3 label May 24, 2022
@chrisbonifacio chrisbonifacio added Core Related to core Amplify issues and removed API Related to REST API issues labels May 25, 2022
@mcnamara-charles
Copy link

I'm still getting this. No Auth component, here's my package.json:

{
  "name": "react-amplified",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^6.1.1",
    "@fortawesome/free-solid-svg-icons": "^6.1.1",
    "@fortawesome/react-fontawesome": "^0.1.18",
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.2.0",
    "@testing-library/user-event": "^13.5.0",
    "aws-amplify": "^4.3.24",
    "framer-motion": "^6.3.6",
    "react": "^18.1.0",
    "react-dom": "^18.1.0",
    "react-router-dom": "^6.3.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

@khatruong2009
Copy link
Member

Hi James,

The code is inside a try-catch and is there to make sure that the user is given UnAuth credentials. Although an error is being logged, the functionality is still the same. I have submitted a pull request to fix this issue (and another similar one) and remove the logging of the error when a user pool is not present.

Thanks,
Kha

@dreamorosi
Copy link

Hi @stocaaro I see that you have closed the issue and the PR has been merged, any indication is the fix has already been released? If not, will it be in the next release?

@khatruong2009
Copy link
Member

Hi @dreamorosi,

This fix was released in the 2022-08-01 Amplify release: aws-amplify@4.3.30.

Thanks,
Kha

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 bug Something isn't working Core Related to core Amplify issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants