private AdminLinkProviderForUserResponse LinkProviderToExistingUser( dynamic input, string provider, string id, UserType existingUser) { //Link the incoming identity to the existing user. Will add an "identity" to the "Identities" array, and allow the existing user to login using the new social login var linkResponse = _client.AdminLinkProviderForUserAsync( new AdminLinkProviderForUserRequest { UserPoolId = input.userPoolId, SourceUser = new ProviderUserIdentifierType { ProviderName = provider, ProviderAttributeName = "Cognito_Subject", ProviderAttributeValue = id }, DestinationUser = new ProviderUserIdentifierType { ProviderName = "Cognito", ProviderAttributeValue = existingUser.Username } }).Result; return(linkResponse); }