简体   繁体   English

用auth打破aws放大?

[英]Is aws-amplify with auth broken?

I am trying to build a react app which will use the aws hosted ui for authentication. 我正在尝试构建一个反应应用程序,它将使用aws托管的ui进行身份验证。 I am trying to use aws-amplify to achieve this, and so far I am having no such luck. 我正在尝试使用aws-ampl来实现这一点,到目前为止我没有这样的运气。

Here the docs state that the auth config should look like this. 这里的文档声明auth配置应该如下所示。

const oauth = {
  domain : 'your-domain-prefix.auth.us-east-1.amazoncognito.com', 
  scope : ['phone', 'email', 'profile', 'openid','aws.cognito.signin.user.admin'], 
  redirectSignIn : 'http://www.example.com/signin/', 
  redirectSignOut : 'http://www.example.com/signout/',
  responseType: 'code',
}

But when I use this config setup I get the following error. 但是当我使用此配置设置时,我收到以下错误。

The parameters: App client Id, App web domain, the redirect URL when you are signed in and the redirect URL when you are signed out are required. 参数:App客户端ID,应用程序Web域,登录时的重定向URL以及注销时的重定向URL。

As you can see, those params are clearly supplied. 如你所见,这些参数显然是供应的。 So I clicked on the source map file linked in my console with the error message, and saw this. 所以我点击了我的控制台中链接的源映射文件和错误消息,并看到了这一点。

if (data == null || !ClientId || !AppWebDomain || !RedirectUriSignIn || !RedirectUriSignOut) {
      throw new Error(this.getCognitoConstants().PARAMETERERROR);
    }

Which makes it seem more like the config should look a little something like this. 这使得看起来更像配置应该看起来像这样的东西。

const auth = {
  AppWebDomain: "aaaaa",
  TokenScopesArray: ["phone", "email", "profile", "openid", "aws.cognito.signin.user.admin"],
  RedirectUriSignIn: "http://localhost:3000",
  RedirectUriSignOut: "http://localhost:3000",
  responseType: "token",
  ClientId: "aaa",
  UserPoolId: "aaa",
};

But when doing this, and trying to send the user to the hosted ui as the docs say here I get this error. 但是当这样做,并尝试将用户发送到托管的UI时,文档在这里说我得到了这个错误。

Uncaught TypeError: Cannot read property 'domain' of undefined 未捕获的TypeError:无法读取未定义的属性“domain”

Once again I looked at the source and found this. 我再次查看源代码并发现了这一点。

var domain = config.domain,

Which makes it seem like its expecting the config which does not work. 这使得它似乎期待配置不起作用。

At this point I am really lost and can use any help at all. 在这一点上,我真的迷失了,可以使用任何帮助。

Going through the Auth.ts code, it appears that you have to include the userPoolId and userPoolWebClientId fields, in addition to oauth . 通过Auth.ts代码,除了oauth之外,您还必须包含userPoolIduserPoolWebClientId字段。 Here's how I got it to work: 以下是我如何使用它:

const oauth = {
  domain: 'XXXXXX.auth.us-west-2.amazoncognito.com',
  scope: ['phone', 'email', 'profile', 'openid', 'aws.cognito.signin.user.admin'],
  redirectSignIn: 'http://localhost:3000/',
  redirectSignOut: 'http://localhost:3000/',
  responseType: 'code'
};
Auth.configure({
  oauth: oauth,
  region: 'us-west-2',
  userPoolId: 'us-west-2_XXXXXXXXX',
  userPoolWebClientId: 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM