该问题可能是由于未正确配置AWS Cognito身份池或身份提供程序而导致的。请确保您的身份池和身份提供程序已正确配置。您也可以尝试使用AWS Amplify的以下代码示例来解决此问题:
import Amplify, { Auth } from 'aws-amplify';
Amplify.configure({
Auth: {
identityPoolId: 'YOUR_IDENTITY_POOL_ID',
region: 'YOUR_REGION',
userPoolId: 'YOUR_USER_POOL_ID',
userPoolWebClientId: 'YOUR_APP_CLIENT_ID',
mandatorySignIn: true,
},
});
Auth.federatedSignIn('cognito-idp.{region}.amazonaws.com/{userPoolId}', {token: '...', expires_at: some_number, code: '...', scope: '...'}, {customState: 'customState'})
.then(credentials => {
console.log(credentials);
})
.catch(e => {
console.log(e);
});
请注意,其中'YOUR_IDENTITY_POOL_ID”、'YOUR_REGION”、'YOUR_USER_POOL_ID”和'YOUR_APP_CLIENT_ID”应替换为您的AWS Cognito身份池ID、区域、用户池ID和应用程序客户端ID。