(AWS Amplify)<Authenticator />组件仅通过基本设置显示“正在加载...”

时间:2019-10-28 11:17:37

标签: reactjs amazon-web-services amazon-cognito aws-amplify amplifyjs

loading

如果我不提供amplifyConfig道具,它将正常渲染(当然它不能实际登录/注册)。

但是,如果我放amplifyConfig属性,只会显示Loading...。

隐藏加载组件时,它什么也没显示。

我仅使用默认的auth配置配置了社交提供程序,即使没有联合道具也是如此。

如何使Authenticator组件正常工作?我想搜索一个关键字。

  • 使用调试工具,我检测到authState只是在“加载”中
  • 当我执行Auth.signOut()时,似乎可以正常工作。但是这种情况下,只要用户使用该应用程序,就会被迫退出。因此不可靠。
  • 将authState属性设置为'signIn'无效
  • withAuthenticator HOC可以工作。但是,即使使用Authenticator,当我配置联合道具时,由于未知原因,每个提供程序的按钮也不起作用。 (我不知道这是相关的问题)
My code is roughly like this

function App ({ authState }) {
  return (
  authState === 'signedIn' ? (
    <div>
      {something}
    </div>
  ) : <div />
  )
}

const federated = {
  google_client_id: '86070459099-1fl345l9jddl8kpuemv08kpsic3jrha2.apps.googleusercontent.com',
  facebook_app_id: '1173021809562416',
  amazon_client_id: ''
}

class AppWithAuth extends Component {
  render () {
    return (
      <Authenticator
        amplifyConfig={awsconfig}
      >
         <App />
      </Authenticator>
    )
  }
}

// export default withAuthenticator(FullWindow, true, [], federated, {})
// export default FullWindow
export default AppWithAuth

my awsconfig

// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.

const awsmobile = {
    "aws_project_region": "us-east-1",
    "aws_cognito_identity_pool_id": "us-east-1:5c6a10e4-b89e-4733-bdeb-20b257bbf7fd",
    "aws_cognito_region": "us-east-1",
    "aws_user_pools_id": "us-east-1_n0MOhpx2p",
    "aws_user_pools_web_client_id": "4dub9op9hjj61c6u64j0g6n790",
    "oauth": {
        "domain": "learnobit69bcc274-69bcc274-master.auth.us-east-1.amazoncognito.com",
        "scope": [
            "phone",
            "email",
            "openid",
            "profile",
            "aws.cognito.signin.user.admin"
        ],
        "redirectSignIn": "http://localhost:5000/",
        "redirectSignOut": "http://localhost:5000/",
        "responseType": "code"
    },
    "federationTarget": "COGNITO_USER_POOLS"
};


export default awsmobile;

0 个答案:

没有答案