简体   繁体   中英

AWS Cognito Associated with Google as an Identity Provider Doesn't Work

I have a cognito user pool which is associated with an identity pool. Cognito works fine, but when i added Google as an identity provider, i don't know how it is going to work. I did all steps in the documentation.

I mean when a user sign in on my website with Google. I can get all Google credentials of the user, id_token, name, email and so on.

In my api-gateway i need an Identity token for to pass ( method.request.header.Authorization ). But when i log in with Google, it generates an id_token which i can not use for my api-gateways.

What i can do with this id_token is using signinCallback() and getting AWS.config.credentials; _identityId, sessionToken, accessKeyId, thus all webIdentityCredentials of the user. But i can do nothing with all these, since i need an id_token which is generated by Cognito.

function signinCallback() {    

    AWS.config.credentials = new AWS.CognitoIdentityCredentials({
        IdentityPoolId: poolId,
        Logins: {
            'accounts.google.com': id_token }
    });

    AWS.config.region = 'eu-west-1';

    // Obtain AWS credentials
    AWS.config.credentials.get(function (err) {
        if (err) {
            console.log(err);
        }
        else {
            console.log(AWS.config.credentials);
        }
    });
}

How can i generate a valid id_token with this credentials?

您必须使用google auth,并且该认知选项适用于“ google plus”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM