Amazon web services AWS Cognito与Microsoft登录(AD)

Amazon web services AWS Cognito与Microsoft登录(AD),amazon-web-services,amazon-cognito,openid,Amazon Web Services,Amazon Cognito,Openid,我正在尝试添加与Microsoft的签名。该网站已经有谷歌登录。以下代码来自AWS文档,并成功运行: const getAWSCredentials = async googleUser => { const { id_token, expires_at } = googleUser.getAuthResponse(); const profile = googleUser.getBasicProfile(); const user = { email: profi

我正在尝试添加与Microsoft的签名。该网站已经有谷歌登录。以下代码来自AWS文档,并成功运行:

const getAWSCredentials = async googleUser => {
    const { id_token, expires_at } = googleUser.getAuthResponse();
    const profile = googleUser.getBasicProfile();
    const user = { email: profile.getEmail(), name: profile.getName()};
    await Auth.federatedSignIn('google', { token: id_token, expires_at }, user);
};
对于microsoft登录,我使用下一个代码:

function MicrosoftButton() {
    const authHandler = (err, data) => {
        if (!err && data) {
            const user = data.authResponseWithAccessToken.account;
            const token = {
                token: data.authResponseWithAccessToken.accessToken,
                expires_at: data.authResponseWithAccessToken.expiresOn,
            };
            (async () => {
                const result = await Auth.federatedSignIn(
                    'microsoft',
                    token,
                    user,
                );
                console.log(result);
            })();
        }
    };
    
    return (
        <MicrosoftLogin clientId={YOUR_CLIENT_ID} authCallback={authHandler} />
    );
}
函数MicrosoftButton(){
常量authHandler=(错误,数据)=>{
if(!err&&data){
const user=data.authResponseWithAccessToken.account;
常量令牌={
令牌:data.authResponseWithAccessToken.accessToken,
expires_位于:data.authResponseWithAccessToken.expiresOn,
};
(异步()=>{
const result=wait Auth.federatedSignIn(
"微软",,
代币
用户,
);
控制台日志(结果);
})();
}
};
返回(
);
}
但我得到一个错误:“未处理的拒绝(NotAuthorizedException):无效的登录令牌。颁发者与providerName不匹配”。我做错了什么?