SSO
Add Reddit sign-in to VitNode. Create a Reddit web app, register the redirect URI, set a User-Agent and confirm new members' email by link.
Add a Continue with Reddit button that asks only for the identity scope, so it can't post, vote or moderate. Reddit never shares an email address, so new members confirm one by email.
Before you begin
- A running VitNode app. This page covers only the Reddit parts; SSO setup explains the shared steps and where the API's
.envand config live. - Approved access to Reddit's Data API. Under Reddit's Responsible Builder Policy (November 2025), new OAuth tokens need Reddit's approval, so creating an app alone may not be enough. Check the policy for the current request process before you rely on Reddit sign-in.
- An email adapter. Without one, VitNode cannot send the confirmation link and new Reddit visitors cannot register.
Set up the app
Create a web app
Sign in to Reddit, open reddit.com/prefs/apps and press create another app.... Choose the web app type. The other types cannot keep a secret.
Add the redirect URI
Fill in the name and description people will see, and set redirect uri:
| Environment | Redirect URI |
|---|---|
Development (VITNODE_WEB_URL unset) | http://localhost:3000/login/sso/reddit |
| Production | https://your-domain.com/login/sso/reddit |
Reddit's app form takes a single redirect URI, so use a separate app for development. VitNode builds the URI from VITNODE_WEB_URL, so it must match exactly. Press create app.
Copy the credentials
The client ID is the short string under the app's name; the secret is next to secret. Keep both server-side, and set a descriptive User-Agent, because Reddit heavily rate-limits generic ones:
REDDIT_CLIENT_ID=AbCdEfGhIjKlMnOpQrStUv
REDDIT_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
REDDIT_USER_AGENT="web:com.example.forum:1.0.0 (by /u/your_username)"Without userAgent, VitNode sends web:{clientId}:1.0 (by VitNode).
Add the adapter
Add RedditSSOApiPlugin to authorization.ssoAdapters in the API's vitnode.api.config.ts (where it lives), next to any adapters you already have. Keep the rest of the config as it is:
import { RedditSSOApiPlugin } from '@vitnode/core/api/adapters/sso/reddit'
import { buildApiConfig } from '@vitnode/core/vitnode.config'
export const vitNodeApiConfig = buildApiConfig({
// ...
authorization: {
ssoAdapters: [
// ...
RedditSSOApiPlugin({
clientId: process.env.REDDIT_CLIENT_ID,
clientSecret: process.env.REDDIT_CLIENT_SECRET,
userAgent: process.env.REDDIT_USER_AGENT,
}),
],
},
})No authorization block yet? Create one with just ssoAdapters, as in the SSO setup. Then restart the dev server, since .env and the API config are only read at start-up.
Check the result
Open /login, press the Reddit button under Continue with and press Allow. The first time, VitNode asks for an email and sends a confirmation link. Open it in the same browser. Next time, the same Reddit account signs straight in.
Scopes and profile fields
| Setting | Value |
|---|---|
| Scopes | identity, with duration=temporary (no refresh token) |
| Token auth | HTTP Basic, with the User-Agent |
| Account ID | id (Reddit's account ID, not the username) |
| never shared; confirmed by email | |
| Profile fields | avatar |
The username becomes the new account's display name. A renamed or deleted Reddit username does not change the stored account ID.
Troubleshooting
- Reddit shows a redirect URI error. The app's redirect URI differs from
{VITNODE_WEB_URL}/login/sso/reddit. - Sign-in fails after Allow, with a provider error. The app is not of the web app type, the secret is wrong, or Reddit is rate limiting a generic User-Agent.
- New visitors see "We need a verified email". No email adapter is configured.