Use Cases
User Authentication
Allow users to sign in to your application with their Polar account:- Seamless single sign-on (SSO)
- Access to user profile, email, and organizations
- No need to manage passwords
API Access
Access Polar’s API on behalf of users or organizations:- Read and manage products
- Create checkout sessions
- Access orders and subscriptions
- Manage customers and webhooks
Multi-Organization Apps
Build apps that work across multiple Polar organizations:- Users grant access to specific organizations
- Separate tokens per organization
- Fine-grained permission scopes
OAuth 2.0 Flow
Polar supports the Authorization Code Flow, the most secure OAuth flow for web applications:Key Concepts
OAuth Client: Your application registered in Polar. Each client has:client_id: Public identifierclient_secret: Secret key for token exchange (keep secure!)- Redirect URIs: Allowed URLs for receiving authorization codes
user or organization.
Subject Types
Polar supports two subject types:User Subject (sub_type: user)
Access APIs as the authenticated user:
- Read user profile and email
- List user’s organizations
- Perform actions as the user
Organization Subject (sub_type: organization)
Access APIs as a specific organization:
- Read and manage organization resources (products, customers, orders)
- Create checkouts and webhooks
- Access organization-specific data
Most integrations should use organization subject type to access organization data. Use user subject type only for personal user data.
Available Scopes
Scopes define what your application can access. Users see these in the consent screen.Identity Scopes
openid- Required for OpenID Connectprofile- Read user profile (name, avatar)email- Read user email address
Resource Scopes
Each resource has separate read and write scopes:products:read/products:write- Products and pricingorders:read/orders:write- Orders and transactionssubscriptions:read/subscriptions:write- Subscriptionscustomers:read/customers:write- Customer recordscheckouts:read/checkouts:write- Checkout sessionsbenefits:read/benefits:write- Benefits and grantswebhooks:read/webhooks:write- Webhook endpointsfiles:read/files:write- File uploadsmetrics:read- Analytics and metrics
Token Prefixes
Polar uses prefixed tokens for easy identification and security scanning:Security Best Practices
Use HTTPS
All redirect URIs must use HTTPS in production. HTTP is only allowed forlocalhost during development.
Validate State Parameter
Always use thestate parameter to prevent CSRF attacks:
Use PKCE
For public clients (mobile, SPA), use PKCE (Proof Key for Code Exchange):Secure Token Storage
- Store tokens server-side when possible
- Encrypt tokens at rest
- Use secure session cookies for web apps
- Never expose tokens in URLs or logs
Handle Token Expiration
Access tokens expire after 1 hour. Use refresh tokens to obtain new access tokens:Rate Limits
Polar’s API has rate limits to ensure fair usage:- User tokens: 1000 requests per hour
- Organization tokens: 5000 requests per hour
429 Too Many Requests response with a Retry-After header.
Testing & Development
Localhost Redirect URIs
You can usehttp://localhost and http://127.0.0.1 for local development:
Multiple Redirect URIs
Register multiple redirect URIs for development, staging, and production:Test Users
Create test organizations in Polar’s dashboard to test your OAuth integration without affecting production data.Well-Known Endpoints
Polar exposes OAuth 2.0 discovery endpoints: Authorization Server Metadata:Next Steps
Creating an OAuth App
Register your application and get credentials
OAuth Connection Flow
Implement the authorization code flow