AWS Cognito:通过 google 获取“请提供有效的公共提供商”

AWS Cognito: getting "Please provide a valid public provider" with google

本文关键字:有效 提供商 Cognito 通过 google 获取 AWS      更新时间:2023-09-26

当我尝试像这样设置 google 访问令牌时,我得到 400"请提供有效的公共提供者":

AWS.config.update(
{
    region: window.region,
    credentials: new AWS.CognitoIdentityCredentials(
    {
        IdentityPoolId: window.identityPoolId,
        Logins:
        {
            'accounts.google.com': gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse().id_token
        }
    })
});

Cognito 是这样启动的:

window.region = Pointer_stringify(region);
window.identityPoolId = 'us-east-1:xxxxxxxx-xxxx-xxxx-xxxx-xxxx';
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = '/aws-sdk.min.js';
po.onload = function()
{
    var po2 = document.createElement('script');
    po2.type = 'text/javascript';
    po2.async = true;
    po2.src = '/amazon-cognito.min.js';
    po2.onload = function()
    {
        AWS.config.region = window.region; // Region
        AWS.config.credentials = new AWS.CognitoIdentityCredentials(
        {
            IdentityPoolId: window.identityPoolId,
        });
    }
    var s2 = document.getElementsByTagName('script')[0];
    s2.parentNode.insertBefore(po2, s2);
}
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);

我已将Google客户端ID添加到身份验证提供商的Google+选项卡中,accounts.google.com 添加到OpenID选项卡中。这只发生在谷歌身上,它适用于Facebook。

问题是我的身份池指向已删除的用户池。

您可能会看到此错误的原因之一是,如果已将池配置为经过开发人员身份验证的流,并且提供程序名称为"accounts.google.com"。您能否在 Cognito 控制台中检查池中的自定义身份验证提供程序,并确保它未设置为"accounts.google.com"?