gpt4 book ai didi

javascript - aws-amplify with auth 损坏了吗?

转载 作者:行者123 更新时间:2023-11-30 09:16:51 24 4
gpt4 key购买 nike

我正在尝试构建一个将使用 aws 托管 ui 进行身份验证的 React 应用程序。我正在尝试使用 aws-amplify 来实现这一点,但到目前为止我还没有这样的运气。

Here文档说明身份验证配置应如下所示。

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',
}

但是当我使用此配置设置时,出现以下错误。

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.

如您所见,这些参数已明确提供。因此,我单击了控制台中链接的带有错误消息的源映射文件,并看到了这个。

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",
};

但是当这样做时,并尝试将用户发送到托管用户界面,如文档所说 here我收到此错误。

Uncaught TypeError: Cannot read property 'domain' of undefined

我再次查看源代码并找到了这个。

var domain = config.domain,

这让它看起来像是在期待配置不起作用。

在这一点上,我真的迷路了,需要任何帮助。

最佳答案

通过 Auth.ts 代码,除了 之外,您似乎还必须包含 userPoolIduserPoolWebClientId 字段>oauth。这是我如何让它工作的:

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'
});

关于javascript - aws-amplify with auth 损坏了吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54539234/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com