itsource

AuthError - 오류: 증폭이 올바르게 구성되지 않았습니다.

mycopycode 2023. 3. 23. 22:43
반응형

AuthError - 오류: 증폭이 올바르게 구성되지 않았습니다.

먼저 다음을 사용하여 리액트 응용 프로그램 구성을 완료했습니다.amplify configureAWS Amplify docs의 도움으로 그렇게 했습니다.그 후, 다음을 사용하여 인증확대 프로젝트에 성공적으로 추가했습니다.amplify add auth그리고.amplify pushAWS - Authentication with Amplify Doc의 모든 단계를 따랐습니다.

나의App.js이렇게 생겼는데

import React from 'react';
import { withAuthenticator, AmplifySignOut } from '@aws-amplify/ui-react';
import Amplify, { Auth } from 'aws-amplify';
import awsconfig from './aws-exports';

Amplify.configure(awsconfig);


const App = () => (
    <div>
        <AmplifySignOut />
        My App
    </div>
);

export default withAuthenticator(App);

하지만 내가 노력하면npm start, 다음의 에러가 표시됩니다.

나는 이 github-issue에서 이 문제에 대한 해결책을 찾았다.

수정은 간단했다.문서 증폭은 다음 구성 로드 여부를 알려주지 않습니다.aws-exports로.Auth module.

이 간단한 코드 행 추가App.js문제를 해결해주었습니다.

import Amplify, { Auth } from 'aws-amplify';
import awsconfig from './aws-exports';

Amplify.configure(awsconfig);

// >>New - Configuring Auth Module
Auth.configure(awsconfig);
  • npm un aws-module @aws-module/ui-module
  • npm i aws-module @aws-module/ui-module

이건 나한테 효과가 있었어.감사합니다 @Ignacio

설치된 앰프 모듈 간의 불일치로 인해 다양한 앰프 모듈 버전에서 이 문제가 발생하는 것 같습니다.저의 경우 아래와 같이 재설치하면 여러 번 해결되었습니다.

npm uninstall --save aws-amplify @aws-amplify/ui-react @aws-amplify/ui-components

npm install --save aws-amplify @aws-amplify/ui-react @aws-amplify/ui-components

사용하는 경우 @aws-amplify/ui-components를 재설치해야 할 경우가 있습니다.

Yarn을 사용하는 경우 이 문제는 의존관계 트리와 버전 업데이트를 관리하는 방법에 따라 패키지 매니저가 충돌하기 때문에 발생할 수 있습니다.

이 문제가 반복적으로 발생하는 경우 시나리오에 따라 Npm을 사용해 보십시오.

Yarn을 사용하는 경우 먼저 Yarn.lock과 node_modules 디렉토리를 삭제해야 합니다.npm install

또한 위의 답변도 참조하십시오.

엑스포에서 TODO 앱을 하다가 같은 문제에 직면했다.구성 파일의 올바른 경로를 추가해야 했습니다.패스가 다르다aws-exports문서에는 기재되어 있지 않습니다.예제 코드는 다음과 같습니다.

import awsconfig from './src/aws-exports'

Amplify.configure(awsconfig);
Auth.configure(awsconfig);

import { createTodo } from './src/graphql/mutations'
import { listTodos } from './src/graphql/queries'
import { withAuthenticator } from 'aws-amplify-react-native'

amplify update auth 실행

[ Walk through all auth configurations ]를 선택합니다.

는, 미인증 로그인을 유효하게 하고, 그 외의 설정은 그대로 합니다.

출처: https://docs.amplify.aws/lib/graphqlapi/authz/q/platform/js/#using-amplify-graphql-client

AWS_를 사용하는 경우공용 API 액세스를 위한 IAM, 인증되지 않은 로그인을 사용하도록 설정해야 합니다.인증되지 않은 로그인을 이노블로 만들려면 명령줄에서 amplify update auth를 실행하고 Walkthrough all auth configurations를 선택합니다.

이것은 graphQL API와 함께 나의 문제를 해결했다.

이 에러는 현재 @aws-amplify/ui-react를 설치하지 않고 있습니다.Auth가 버전3에서 4로 변경되어 문제의 원인이 된 것 같습니다.

If you are following a tutorial here are some precautions that might be helpful to you and save you same headache.
Use modules and dependencies that the tutor of the tutorial is using. Do not assume anything.

in package.json file write the dependencies and version as guided by the tutorial and at the end dont run npm install.
why? npm install pops up ERR errors that are headaches. Use yarn install and it will fix your errors.

e.g
in my project's package.json file i have the following::
{

"version": "0.1.0",
  "private": true,
  "dependencies": {
    "@aws-amplify/ui-react": "^0.2.9-unstable.12",
    "@stripe/react-stripe-js": "^1.9.0",
    "@stripe/stripe-js": "^1.32.0",
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^13.5.0",
    "aws-amplify": "^4.3.26",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-icons": "^3.8.0",
    "react-router-dom": "^6.3.0",
    "react-scripts": "5.0.1",
    "react-stripe-elements": "^6.0.1",
    "stripe": "^9.10.0",
    "uuid": "^7.0.0",
    "web-vitals": "^2.1.4"
  },
}


from the guide of the tutorial.But from react all these dependencies are old some obsolete. What do i do? I dont install each individual to bring confusion in modules by just running yarn install to align them and erradicet errors.

언급URL : https://stackoverflow.com/questions/63605779/autherror-error-amplify-has-not-been-configured-correctly

반응형