Javascript aws是否使用auth进行放大?
我正在尝试构建一个react应用程序,它将使用aws托管的ui进行身份验证。我正在尝试使用aws amplify来实现这一点,到目前为止我还没有这样的运气 文档声明auth配置应该如下所示Javascript aws是否使用auth进行放大?,javascript,reactjs,amazon-cognito,aws-amplify,Javascript,Reactjs,Amazon Cognito,Aws Amplify,我正在尝试构建一个react应用程序,它将使用aws托管的ui进行身份验证。我正在尝试使用aws amplify来实现这一点,到目前为止我还没有这样的运气 文档声明auth配置应该如下所示 const oauth = { domain : 'your-domain-prefix.auth.us-east-1.amazoncognito.com', scope : ['phone', 'email', 'profile', 'openid','aws.cognito.signin.use
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',
}
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",
};
但是当我使用这个配置设置时,我得到了以下错误
参数:应用程序客户端Id、应用程序web域、重定向URL
您已登录,注销时的重定向URL为
必需的
正如您所看到的,这些参数是明确提供的。因此,我点击了控制台中带有错误消息的源映射文件,并看到了这一点
if (data == null || !ClientId || !AppWebDomain || !RedirectUriSignIn || !RedirectUriSignOut) {
throw new Error(this.getCognitoConstants().PARAMETERERROR);
}
这使得配置看起来更像是这样
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',
}
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:无法读取未定义的属性“域”
我再一次看了看来源,发现了这个
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'
});
您是否也可以从aws发布(或再次检查)您的cognito配置(应用程序客户端设置的clientWeb,域名)?这些条目在应用程序和aws中必须相同。