确认您的应用程序已正确配置,并且您的Cognito用户池包含应用程序客户端。
确认您正确设置了Authorization Endpoint和Token Endpoint。
确认您正确设置了回调URL,以便在用户登录后将其重定向回您的应用程序。
以下是设置回调URL和重定向URI以在Cognito中使用Hosted UI的示例代码:
const authData = {
ClientId: 'YOUR_APP_CLIENT_ID',
RedirectUri: 'YOUR_REDIRECT_URI',
ResponseType: 'code',
Scope: 'openid email profile',
State: 'YOUR_STATE'
};
const authParameters = AWS.CognitoIdentityServiceProvider.CognitoAuth.getAuthParameters(authData);
this.cognitoAuth.launchUri(authParameters);
此代码将使用您提供的应用程序客户端ID,回调URL和作用域启动Hosted UI。 登录后,它将重定向回您提供的回调URL,并以带有授权代码的查询字符串参数的形式发送响应。