kavachOS
Authentication

PayPal

Sign in with PayPal using OAuth 2.0.

Setup

Get credentials

Go to the PayPal Developer Portal and create an app under My Apps & Credentials. Add your redirect URI:

https://your-app.com/api/kavach/auth/oauth/callback/paypal

Make sure to enable Log In with PayPal for the app.

Configure

lib/kavach.ts
import { createKavach } from 'kavachos';
import { oauth } from 'kavachos/auth';

const kavach = await createKavach({
  database: { provider: 'sqlite', url: 'kavach.db' },
  plugins: [
    oauth({
      providers: [
        {
          id: 'paypal',
          clientId: process.env.PAYPAL_CLIENT_ID!,
          clientSecret: process.env.PAYPAL_CLIENT_SECRET!,
        },
      ],
    }),
  ],
});
PAYPAL_CLIENT_ID=...
PAYPAL_CLIENT_SECRET=...

Scopes

Default scopes: openid, email

ScopeWhat it unlocks
openidOIDC identity token
emailEmail address
profileName and locale
addressBilling address

PayPal supports both sandbox and live environments. Use sandbox credentials during development and switch to live credentials before going to production.

Endpoints

MethodPathDescription
GET/auth/oauth/authorize/paypalRedirect to PayPal
GET/auth/oauth/callback/paypalHandle callback

On this page