I want to enable users to sign in with their google, facebook or yahoo account.
Look at using OpenID. All of those sites that you mention actually support OpenID, and many more (including this one) do too.