Overview
This guide walks you through setting up OAuth 2.0 authentication for the GetBill API. OAuth 2.0 provides secure, standardized authorization that allows your application to access GetBill data on behalf of your company.Why OAuth 2.0?
Security
Your credentials are never stored in the client application. Tokens can be revoked without changing passwords.
Scoped Access
Request only the permissions your application needs. Users can see exactly what access they’re granting.
Standardized
OAuth 2.0 is an industry standard supported by all major platforms and programming languages.
Scalable
Suitable for everything from simple scripts to large enterprise integrations.
Step 1: Create an OAuth Client
Access Your Dashboard
- Log in to your GetBill account
- Navigate to Company
- Find the API Client Management section
- Click Create New OAuth Client
Configure Your Client
API clients use Client Credentials automatically for server-to-server authentication. There is no authentication flow to select.
Save Your Credentials
After creating the client, you’ll receive:string
Public identifier for your application (safe to store in client-side code)
string
Secret key for your application (keep this secure!)
Step 2: Request an Access Token
Client Credentials Flow
Best for: Server-to-server applications, background jobs, automated systems When to use:- Your application runs on a secure server
- No user interaction is required
- You’re accessing your own company’s data
- Your application requests a token directly from the authorization server
- No user authorization step is required
- Token is returned immediately
Step 3: Implementation Examples
Client Credentials Implementation
- JavaScript (Node.js)
- Python
- PHP
Step 4: Security Best Practices
Secure Token Storage
- Use environment variables for client secrets
- Store tokens securely (encrypted database, secure session storage)
- Never log or expose tokens in error messages
Minimal Scopes
- Request only the scopes your integration needs
- Review granted scopes regularly
- Remove permissions that are no longer required
HTTPS Only
- Always use HTTPS for all OAuth flows
- Validate SSL certificates
- Never send tokens over unencrypted connections
Token Management
- Request a new token before expiration
- Handle token expiration gracefully
- Revoke tokens when no longer needed
Environment Variables Example
Step 5: Testing Your Setup
Test Client Credentials
Troubleshooting
invalid_client Error
invalid_client Error
Cause: Incorrect client ID or secretSolution:
- Double-check your client credentials
- Ensure you’re using the correct environment (test vs production)
- Verify the client is active in your dashboard
invalid_scope Error
invalid_scope Error
Cause: Requesting scopes not granted to your clientSolution:
- Check your client configuration in the dashboard
- Request only the scopes you need
- Contact support if you need additional scopes
unsupported_grant_type Error
unsupported_grant_type Error
Cause: Invalid or unsupported grant typeSolution:
- Send
grant_type=client_credentials - Use the
/oauth/tokenendpoint - Check that the request body uses form encoding
Production Considerations
Scaling OAuth
- Token Caching: Cache tokens in Redis or similar for multiple server instances
- Secure Storage: Store client credentials in a secrets manager
- Rate Limiting: Avoid unnecessary token requests by reusing valid access tokens
- Monitoring: Monitor token issuance and API authentication failures
Security Hardening
- Certificate Pinning: Pin SSL certificates for additional security
- Token Rotation: Regularly rotate client secrets
- Audit Logging: Log all OAuth events for security monitoring
- Scope Minimization: Use the minimum required scopes
Next Steps
Once OAuth is set up:- Make your first API call
- Explore the API Reference documentation
- Set up webhooks for real-time updates
- Review best practices for production use