BuildPass supports OAuth 2.0 Authorization Code Grant with PKCE (Proof Key for Code Exchange) for integrator applications that need to access builder data on behalf of users. This flow is ideal for third-party applications that require user consent.Documentation Index
Fetch the complete documentation index at: https://developer.buildpass.global/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Authorization Code flow allows your application to:- Direct users to BuildPass for authentication and consent
- Receive an authorization code after user approval
- Exchange the code for access and refresh tokens
- Use access tokens to make API requests on behalf of the user
- Use refresh tokens to obtain new access tokens
When to Use This Flow
Use the Authorization Code flow when:- Your application needs to access BuildPass data on behalf of a specific user/builder
- You want users to explicitly authorize your application
- You need long-lived access via refresh tokens
- You’re building a mobile app, SPA, or desktop application (public clients)
- You’re building a backend application that requires user authorization (confidential clients)
For server-to-server integrations without user involvement, use the Client
Credentials flow instead.
External API integrations authorize against
https://api.buildpass.global and
receive tokens for the https://api.buildpass.global audience. BuildPass AI
MCP connectors use regional OAuth and MCP resource URLs, which are separate
from the External API integration audience.Client Types and Authentication
This flow works with both Confidential and Public clients:Confidential Clients
Backend applications that can securely store aclient_secret. Must authenticate with both client_id and client_secret when exchanging codes for tokens.
Examples: Web servers, backend services
Public Clients
Applications that cannot securely store secrets. Authenticate with onlyclient_id and rely on PKCE for security.
Examples: Mobile apps, single-page applications, desktop apps
For public BuildPass AI MCP clients that request
execute:ai_agent_tools, loopback callback hosts are treated as aliases during authorization-code exchange. This allows native MCP clients to authorize with http://127.0.0.1:<port>/callback and exchange the code with http://localhost:<same-port>/callback, or the reverse. The protocol, path, query string, and non-loopback host still need to match.Security Features
BuildPass implements industry-standard security measures:- ✅ PKCE (RFC 7636) - Required for all authorization requests
- ✅ State Parameter - Prevents CSRF attacks
- ✅ Authorization Code Reuse Protection - Codes are single-use only
- ✅ Refresh Token Rotation - New refresh token issued on each use
- ✅ Token Revocation - RFC 7009 compliant revocation endpoint
- ✅ Rate Limiting - Protects against abuse
- ✅ Comprehensive Audit Logging - All authorization events tracked
Flow Diagram
Step-by-Step Implementation
Step 1: Generate PKCE Values
Before redirecting users, generate a code verifier and challenge:Step 2: Redirect User to Authorization Endpoint
Redirect the user to BuildPass for authorization:| Parameter | Description |
|---|---|
client_id | Your application’s client ID |
redirect_uri | Registered callback URL where BuildPass will send the authorization code |
response_type | Must be code |
scope | Space-separated list of requested scopes (e.g., read:builders read:subcontractors) |
code_challenge | Base64-URL-encoded SHA256 hash of your code_verifier |
code_challenge_method | Must be S256 (SHA256) |
state | Random string to prevent CSRF attacks |
| Parameter | Description |
|---|---|
builder_id | Pre-select a specific builder (if user has access to multiple) |
You do not need to send
X-BuildPass-Api-Version for /oauth/authorize.
Browser redirects cannot include custom headers, so this endpoint defaults to
API version v1 when omitted.Step 3: Handle the Authorization Callback
After user approval, BuildPass redirects back to yourredirect_uri with:
Success Response:
Step 4: Exchange Authorization Code for Tokens
Exchange the authorization code for access and refresh tokens: For Confidential Clients:| Parameter | Description |
|---|---|
grant_type | Must be authorization_code |
code | Authorization code from callback |
redirect_uri | Must match the original request |
code_verifier | Original code verifier used to generate the challenge |
client_id | Required for public clients (in request body) |
client_id in the request body:
Step 5: Fetch the authorised user identity
After exchanging the authorization code, callGET /me with the access token to retrieve the BuildPass user identity and the builders they consented for.
The /me response now includes signed asset URLs you can use directly in your integration:
profilePictureUrl- signed URL for the authorised user’s BuildPass profile photo, if one is configuredmemberships[].builderLogoUrl- signed URL for each consented builder’s company logo, if one is configured
- access_token: Use this to make API requests (lifetime: 1 hour)
- refresh_token: Use this to get new access tokens (lifetime: 30 days)
- expires_in: Access token lifetime in seconds (3600 = 1 hour)
- scope: Granted scopes (may differ from requested scopes)
Step 6: Use the Access Token
Include the access token in API requests:Step 7: Refresh the Access Token
When the access token expires, use the refresh token to get a new one: For Confidential Clients:Refresh Token Rotation: BuildPass automatically rotates refresh tokens.
The old refresh token is revoked and a new one is issued. Always store the new
refresh_token from the response.Step 8: Revoke Tokens (Optional)
When a user disconnects your integration or you need to invalidate tokens: For Confidential Clients:| Parameter | Description |
|---|---|
token | The token to revoke (access or refresh token) |
token_type_hint | Optional: access_token or refresh_token |
Per RFC 7009, the endpoint returns
200 OK regardless of whether the token
was found, preventing token scanning attacks.Available Scopes
Request only the scopes your application needs:| Scope | Description |
|---|---|
read:builders | Access builder information |
read:subcontractors | Access subcontractor information |
read:projects | Access project information |
read:insurances | Access insurance certificates |
read:prequalifications | Access prequalification documents |
read:contacts | Access contact information |
read:swms | Access SWMS documents |
read:timesheets | Access timesheet data |
read:inductions | Access induction records |
Scope Changes and Re-Authorization
When you request different scopes:- Users will see a new consent screen showing the updated permissions
- Previous authorization codes and tokens remain valid with their original scopes
- New tokens will include the updated scopes
Token Security Best Practices
Storage Guidelines
For All Clients:- Encrypt tokens at rest - Use your platform’s secure storage
- Never log tokens - Treat them as sensitive credentials
- Use HTTPS only - All communication must be over TLS
- Validate redirect URIs - Ensure they match registered URIs exactly
- Protect client_secret - Store securely using secret managers (AWS Secrets Manager, HashiCorp Vault, etc.)
- Never expose secrets client-side - Keep credentials server-side only
- Use HTTP Basic Auth - Preferred over body parameters
- Rotate credentials periodically - Contact BuildPass for rotation
- Never store tokens in browser localStorage or sessionStorage - Vulnerable to XSS attacks
- Use platform-specific secure storage:
- iOS: Keychain
- Android: KeyStore
- Desktop: OS-specific credential managers
- Implement proper PKCE - Generate cryptographically random verifiers
- Validate state parameter - Prevent CSRF attacks
- Use short-lived in-memory storage where possible for access tokens
Token Handling
Detecting Token Expiration
Error Responses
All OAuth errors follow RFC 6749 standards:| Error Code | Description | HTTP Status |
|---|---|---|
invalid_request | Missing or malformed parameters | 400 |
invalid_client | Invalid client credentials | 401 |
invalid_grant | Invalid/expired authorization code | 400 |
invalid_scope | Requested scopes not allowed | 400 |
access_denied | User denied authorization | 400 |
server_error | Internal server error | 500 |
Rate Limits
OAuth endpoints are rate-limited to prevent abuse:| Endpoint | Limit | Window |
|---|---|---|
/oauth/authorize | 30 requests | 10 seconds |
/oauth/token | 60 requests | 10 seconds |
/oauth/revoke | 30 requests | 10 seconds |
Authorization Code Reuse Protection
Testing Your Integration
Step-by-Step Checklist
- Generate valid PKCE code_verifier and code_challenge
- Construct authorization URL with all required parameters
- Implement state parameter validation in callback
- Handle both success and error callbacks
- Exchange authorization code for tokens within 10 minutes
- Store refresh token securely
- Implement token refresh before expiration
- Handle token revocation
- Test scope permission boundaries
- Test authorization code reuse (should fail)
- Test expired authorization code (should fail)
- Test mismatched redirect_uri (should fail)
- Test invalid code_verifier (should fail)
Example Error Scenarios
Expired Authorization Code:RFC Compliance
BuildPass OAuth implementation is fully compliant with:- ✅ RFC 6749 - OAuth 2.0 Authorization Framework
- ✅ RFC 7636 - Proof Key for Code Exchange (PKCE)
- ✅ RFC 7009 - Token Revocation
- ✅ RFC 6750 - Bearer Token Usage
Support
For questions or issues with OAuth integration:- Email: support@buildpass.com.au
- Documentation: https://docs.buildpass.global
Need help with your integration? Our team is here to assist with
implementation questions and troubleshooting.