首页 > 解决方案 > 与 Auth0 联合在 Amplify React 中不起作用

问题描述

我正在关注这个文档:https://aws-amplify.github.io/docs/js/authentication在 Federated with Auth0 部分,我正在尝试通过我的 Congito React 登录组件设置 Auth0 登录。 登录组件

但是,一旦登录呈现,我就会收到此错误:

[错误] 42:27.234 AuthError - 错误:未正确配置放大。配置对象缺少必需的身份验证属性。您amplify push在通过添加身份验证后运行了amplify add auth吗?有关更多信息,请参阅https://aws-amplify.github.io/docs/js/authentication#amplify-project-setup

我确实运行了放大身份验证然后放大推送,如果我再次运行推送,它说没有要进行的更改

这是我的代码:

import React from 'react';
import logo from './logo.svg';
import './App.css';

import { withAuthenticator } from 'aws-amplify-react';
import { Auth } from 'aws-amplify';

// auth0 configuration, more info in: https://auth0.com/docs/libraries/auth0js/v9#available-parameters
Auth.configure({
    auth0: {
        domain: <MY DOMAIN>.auth0.com, 
        clientID: <AUTH0 CLIENT ID>,
        redirectUri: 'http://localhost:3000/',
        audience: 'https://<MY DOMAIN>.auth0.com/userinfo',
        responseType: 'token id_token', 
        scope: 'openid profile email',
        returnTo: 'http://localhost:3000/'
    }
});


function App() {
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.js</code> and save to reload.
        </p>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header>
    </div>
  );
}

export default withAuthenticator(App);

有谁知道可能是什么问题?

标签: reactjsamazon-cognitoauth0aws-amplify

解决方案


我与 Auth0 社区合作。看起来这似乎与[ERROR] 42:27.234 AuthError - Error: Amplify has not been configured correctly.错误提示的放大有关。虽然我不知道确切的错误细分,但它确实有助于提供一个可以构建的地方。

我确实发现了这个产生类似错误的开放 github 问题:https ://github.com/aws-amplify/amplify-js/issues/4315


推荐阅读