Social login with OAuth

04·Hands-on·12 min

OAuth lets your app ask Google (or Kakao, GitHub, or Apple) "who is this?" without ever seeing the user's password.

  1. Your app sends the user to the provider with your client id.
  2. The user signs in there and approves.
  3. The provider redirects back with a one-time code.
  4. Your server trades that code, plus your client secret, for the user's identity.

The client secret is the part that must never reach a browser. That exchange in step 4 is why social login needs a server.

The redirect URL

In step 3 the provider only sends users back to addresses you registered with it in advance. That is what stops someone from reusing your client id to send a user's code to their own site. It is also the most common setup error: if the registered address differs from the real one by http instead of https, a trailing slash, or a custom domain you forgot to add, the provider refuses with redirect_uri_mismatch.

Apple does it differently

Sign in with Apple runs the same four steps with two twists. There is no fixed client secret to copy. You download a private key once, and the server signs a fresh, short-lived secret with it for every exchange, so no long-lived secret exists to leak. And in step 3 Apple posts the code back as a form instead of putting it in the URL, so the callback has to accept a POST as well as a GET. Apple also shares the person's name only the first time they approve your app, and lets them hide their real email behind a relay address that forwards to it.

Where DontCode fits

Steps 1 to 4 already run for you. Your part is registering your app with the provider: Users, Sign-in settings shows the redirect URL to give them, and the setup guide walks through each provider's console. Paste the client id and secret (for Apple, a Services ID, Team ID, Key ID, and the private key), press Save, and the button goes live with that build. DontCode stores secrets and keys encrypted and write-only: you can replace them, never read them back.

Your task

Insight ProjectBackend Project

In your project, open Users, then Sign-in settings, and under Ways to sign in configure one provider with its client id and secret. The setup guide linked above shows where each provider keeps them.