ZKRINET Docs
Building blocks

Social login — Zkrinet plugin

On Zkrinet: add the block under Building blocks in the panel — one click, your own code is untouched and a snapshot is taken first. The installation steps below apply if you run PocketBase yourself, for example after an export.

Log in with Google, GitHub, Apple, Microsoft, Facebook, Discord and more. Tested against PocketBase 0.40.4.

Honestly, what is what

The login itself is PocketBase's own (OAuth2, around thirty providers). The plugin turns it on, maps name and profile picture from the provider, and adds a check that tells you exactly what is missing. What usually stops people is not the code — it is the settings at Google & co. That is why the guide below is the most important part.

Install

Copy pb_hooks/ and pb_migrations/ into the project and restart. Set Application URL under Settings to your real address (https).

The check

GET /api/zk/social/kontroll        (superuser)

Responds with the callback address you should paste in at the provider, which providers have been added, and warnings (missing or incorrect Application URL, http instead of https, localhost, no provider added).

Add a provider

  1. Get the callback address from the check. It looks like this: https://dinapp.se/api/oauth2-redirect
  2. Create an app at the provider (below) and paste the address in as redirect URI / callback URL.
  3. Copy Client ID and Client secret to the admin panel: Collections → users → ⚙ → OAuth2 → Add provider.
ProviderWhere you create the appPitfall
Googleconsole.cloud.google.com → APIs & Services → Credentials → OAuth client ID (Web)The app must be "published" on the OAuth consent screen, otherwise only test users can log in.
GitHubgithub.com → Settings → Developer settings → OAuth AppsThe easiest of all. A good one to start with.
Microsoftportal.azure.com → App registrationsChoose which accounts are allowed to log in (personal, work or both).
Discorddiscord.com/developers → Applications → OAuth2—
Appledeveloper.apple.com → Identifiers + KeysRequires a paid developer account. Apple also requires Sign in with Apple in iPhone apps that offer other social login. The secret is a key that expires every 6 months.
Facebookdevelopers.facebook.com → My AppsOnly works for yourself until the app is verified as a business app (Business verification).

The button in your app

await pb.collection("users").authWithOAuth2({ provider: "google" })

Which providers are enabled (with name and logo) you fetch without logging in:

const { oauth2 } = await pb.collection("users").listAuthMethods()

Security