system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How does "Login via Facebook/Google/etc" work? How can it be secure to give away my credentials to random sites?
gpt
Your credentials are never sent or known to the random site, but your user info is. This is how it goes:
 
1. You want to login to random site XYZ and that means you want to prove your identity to XYZ (this process is called authentication)
2. When you choose Login via Facebook/Google/etc you are choosing them to prove your identity for you (because they already know you, you are registered there). The way Facebook/Google manages to prove your identity to XYZ depends on the protocol implemented behind the scenes (OAuth, OpenID)
3.  By choosing Facebook/Google to prove your identity, you are knocking on their doors and asking them to give you a letter stating who you are and possibly a few more details about you. Before giving you the letter, you must prove that you are who you claim to be, then, Facebook/Google asks you to prove your identity at their door --> using your username and password.
4. If your username and password are correct, Facebook/Google will issue the letter for you with a security feature like a watermark, something that makes the letter unable to be forged.
5. Then, you go back to XYZ, knock on its door, show the letter. XYZ examines the letter and because of the security feature, XYZ can confirm that your letter is valid and they let you in. (how XYZ knows Facebook/Google's security features is another story).