I am applying Google Login with CognitoCachingCredentialsProvider and AmazonCognitoIdentityClient but user entry added in the identity pool, not in the user pool. I need to get JWT token for auth. I did research on lots of document but no one gives a proper solution. Please help me with how to achieve social login with 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);
I am getting IdToken but I need JWT token for the same. Also, I used this code.
// 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();
I am getting idToken token from google that is id_token.