Skip to main content

Setup

1

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.
2

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
Last modified on April 17, 2026