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/paypalMake sure to enable Log In with PayPal for the app.
Configure
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
| Scope | What it unlocks |
|---|---|
openid | OIDC identity token |
email | Email address |
profile | Name and locale |
address | Billing address |
PayPal supports both sandbox and live environments. Use sandbox credentials during development and switch to live credentials before going to production.
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /auth/oauth/authorize/paypal | Redirect to PayPal |
| GET | /auth/oauth/callback/paypal | Handle callback |