[英]Is aws-amplify with auth broken?
我正在尝试构建一个反应应用程序,它将使用aws托管的ui进行身份验证。 我正在尝试使用aws-ampl来实现这一点,到目前为止我没有这样的运气。
这里的文档声明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',
}
但是当我使用此配置设置时,我收到以下错误。
参数:App客户端ID,应用程序Web域,登录时的重定向URL以及注销时的重定向URL。
如你所见,这些参数显然是供应的。 所以我点击了我的控制台中链接的源映射文件和错误消息,并看到了这一点。
if (data == null || !ClientId || !AppWebDomain || !RedirectUriSignIn || !RedirectUriSignOut) {
throw new Error(this.getCognitoConstants().PARAMETERERROR);
}
这使得看起来更像配置应该看起来像这样的东西。
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",
};
但是当这样做,并尝试将用户发送到托管的UI时,文档在这里说我得到了这个错误。
未捕获的TypeError:无法读取未定义的属性“domain”
我再次查看源代码并发现了这一点。
var domain = config.domain,
这使得它似乎期待配置不起作用。
在这一点上,我真的迷失了,可以使用任何帮助。
通过Auth.ts
代码,除了oauth
之外,您还必须包含userPoolId
和userPoolWebClientId
字段。 以下是我如何使用它:
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.