使用具有Google身份验证的AWS Cognito登录

我正在通过 CognitoCachingCredentialsProvider AmazonCognitoIdentityClient 应用 Google 登录,但用户条目已添加到身份池中,而不是用户池中。我需要获取 JWT令牌以进行身份​​验证。我对大量文档进行了研究,但没有人提供适当的解决方案。请帮助我了解如何使用 AWS Cognito 进行社交登录。

           AmazonCognitoIdentityClient cognitoClient = new AmazonCognitoIdentityClient(AWSConnection.AWS_accessKey,AWSConnection.AWS_SecretKey,AWSConnection.AWSRegion);
        Dictionary<string,string> keyvaluepairs = new Dictionary<string,string>() { };
        keyvaluepairs.Add("accounts.google.com",idToken);
        GetIdRequest idRequest = new GetIdRequest
        {

            //idRequest.accountId = _openIdConnect.ClientId;
            IdentityPoolId = "us-west-2:xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx",// set the Dictionary of logins if you are authenticating users
            // through an identity provider
            Logins = keyvaluepairs
        };

        // The identity id is in the IdentityId parameter of the response object
        GetIdResponse idResp = await cognitoClient.GetIdAsync(idRequest);

        // TODO: At this point,you should save this identifier so you won’t
        // have to make this call the next time a user connects        
        // create a new request object

        GetOpenIdTokenRequest openIdReq  = new GetOpenIdTokenRequest
        {
            IdentityId = idResp.IdentityId,// set the Dictionary of logins if you are authenticating users 
            // through an identity provider
            Logins = keyvaluepairs
        };
        GetOpenIdTokenResponse openIdResp = await cognitoClient.GetOpenIdTokenAsync(openIdReq);

我正在获取IdToken,但我同样需要JWT令牌。 另外,我使用了这段代码。

          // Initialize the Amazon Cognito credentials provider
        CognitoAWSCredentials credentials = new CognitoAWSCredentials(
            "us-west-2:xxxxxxx-xxxx-xxx-xxxx-xxxx",// Identity pool ID
            RegionEndpoint.USWest2 // Region
        );
        credentials.AddLogin("accounts.google.com",idToken);
       var sd  = credentials.getcredentials();

我从Google获得了id_token的idToken令牌。

hufu1971 回答:使用具有Google身份验证的AWS Cognito登录

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3082425.html

大家都在问