Skip to content
Skip to content
PGB Learn

Add social login with Google or GitHub

Register your app with a provider, paste its credentials into the Console, and let people sign in with an account they already have.

Updated Nov 12, 2026

Social login lets people sign in with an account they already have. Your project supports Google and GitHub. You create an OAuth app with the provider, then give its credentials to your project.

Set up a provider

  1. At the provider (for example Google Cloud Console > APIs & Services > Credentials, or GitHub's developer settings), create an OAuth app.
  2. Register your app's callback URL with the provider. This is the page in your app that receives the user after they approve, for example https://app.example.com/callback.
  3. In the Console, open Authentication > Settings > Social login.
  4. Find the provider's card. Paste the Client ID and Client secret.
  5. Choose Save credentials. The card changes from Not configured to Configured.

A Google client ID ends in .apps.googleusercontent.com. The Console checks this and tells you if it does not match.

The secret is stored encrypted and is never shown again. To change it, enter new values and choose Replace credentials. To turn a provider off, choose Remove. Users will no longer be able to use it.

Wire it into your app

The sign-in has two steps. With the TypeScript SDK:

// 1. Ask for the provider's sign-in address
const { authorize_url, state } = await pgb.auth.oauthStart({
  provider: "google",
  redirectUri: "https://app.example.com/callback",
});
// send the browser to authorize_url

// 2. On your callback page, finish the sign-in
const result = await pgb.auth.oauthCallback({
  provider: "google",
  code,           // from the address your app was opened with
  state,
  redirectUri: "https://app.example.com/callback",
});

The result contains the user and a session, just like a password sign-in. The Python, Go and Rust SDKs have the same two calls (oauth_start, oauth_callback).

To see which providers are on, call pgb.auth.getSettings(), so your sign-in page can show only the buttons that will work.

Good to know

  • The state value ties the two steps together and is valid for ten minutes.
  • The callback step is rate limited per address.
  • Social login is separate from the Sign-in methods tab. You can use both side by side.

More guides in Console: authentication