Getting Started with iglooworks code flow integration
Overview
This guide helps you integrate with iglooworks's API using OAuth 2.0 authentication. You'll learn how to:
- Set up authentication
- Obtain and manage access tokens
- Make your first API calls
Prerequisites
Before starting, ensure you have:
- A valid iglooworks business partnership
- Your callback URL ready
- Contact with your BD representative
Authentication Setup
OAuth 2.0 Integration
iglooworks api v2 uses OAuth 2.0 Authorization Code flow (RFC 6749, section 4.1) for secure API access.
This integration enables your users to authenticate with iglooworks account and grants your application access to their smart locks.
Authentication Flow Diagram
The following diagram illustrates the complete OAuth 2.0 authentication flow:
Flow Steps Explained
- User Authentication: User clicks login in your app and is redirected to iglooworks's secure login page
- Authorization Code: After successful login, user is redirected back with a temporary authorization code
- Token Exchange: Your app exchanges the authorization code for long-lived tokens
- Secure Storage: Store tokens and calculated expiry times in your secure database
- API Access: Use the access token to make API calls to igloohome services
- Token Refresh: Proactively refresh tokens before they expire to maintain seamless access
Getting Started
Current Process: Manual onboarding (automated portal coming soon)
Required Steps:
- Contact your BD representative or our integration team
- Provide your callback URL
- Receive your client ID
Static Redirect URI
Your callback URL must be static and use HTTPS. Dynamic URLs or HTTP are not supported.
What You'll Need:
- Callback URL (must be HTTPS)
- Client ID (provided by iglooworks)
Scopes and Permissions
Scopes define what your application can access. Format Space-separated list of scope names
Important
If no scopes are specified, all permissions are granted.
Available Scopes
| Scope | Description |
|---|---|
iglooworksapi/create-custom-pin-permanent-job |
Create a job for a permanent custom PIN |
iglooworksapi/create-custom-pin-duration-job |
Create a job for a duration-based custom PIN |
iglooworksapi/create-custom-pin-onetime-job |
Create a job for a one-time custom PIN |
iglooworksapi/unlock-bridge-proxied-job |
Unlock devices via bridge |
iglooworksapi/lock-bridge-proxied-job |
Lock devices via bridge |
iglooworksapi/create-pin-bridge-proxied-job |
Create custom PINs via bridge |
iglooworksapi/delete-pin-bridge-proxied-job |
Delete custom PINs via bridge |
iglooworksapi/edit-pin-bridge-proxied-job |
Edit custom PINs via bridge |
iglooworksapi/delete-pin-job |
Create a job to delete a PIN |
iglooworksapi/get-devices |
Retrieve device list |
iglooworksapi/get-job-status |
Get the status of a specific job |
iglooworksapi/get-master-pin |
Get the master PIN of a device |
iglooworksapi/get-properties |
Retrieve property list |
iglooworksapi/get-access |
Retrieve access list for a property |
iglooworksapi/get-battery-level-bridge-proxied-job |
Get battery levels via bridge |
iglooworksapi/get-device-status-bridge-proxied-job |
Get device status via bridge |
iglooworksapi/get-activity-logs-bridge-proxied-job |
Get activity logs via bridge |
iglooworksapi/create-ekey-access |
Create eKey access |
iglooworksapi/store-device-activity |
Store device activity |
iglooworksapi/get-device-activity |
Get device activity |
iglooworksapi/get-jobs |
Get a list of jobs |
iglooworksapi/get-job-detail |
Get the details of a specific job |
iglooworksapi/update-job-status |
Update the status of a job |
iglooworksapi/algopin-permanent |
Create permanent access AlgoPINs |
iglooworksapi/algopin-duration |
Create duration-based AlgoPINs |
iglooworksapi/algopin-otp |
Create one-time access AlgoPINs (OTP) |
iglooworksapi/get-departments |
Retrieve department list |
iglooworksapi/get-account-detail |
Get account detail |
Implementation Guide
Initiate Authentication
Redirect users to iglooworks's login page:
Parameters:
| Parameter | Required | Description |
|---|---|---|
response_type |
Yes | Must be code |
client_id |
Yes | Your client ID from iglooworks |
redirect_uri |
Yes | Your callback URL (URL encoded) |
scope |
Yes | Space-separated scope list |
Example Request:
Error Responses
| Error Code | Description | Solution |
|---|---|---|
invalid_request |
Missing required parameter (e.g., grant_type) |
Check all required parameters are included |
invalid_client |
Invalid client ID or secret | Verify credentials with iglooworks team |
invalid_scope |
Requested scope not available | Use only supported scopes from the list above |
invalid_grant |
Authorization code expired or already used | Request new authorization code |
Successful Authentication
After successful authentication, the server redirects to your callback URL with an authorization code:
Exchange Authorization Code for Tokens
Make a POST request to exchange the authorization code for access tokens:
Example Request:
Success Response
Response Fields
| Field | Description |
|---|---|
id_token |
Contains user identity claims (name, email) |
access_token |
JWT token for API authentication |
refresh_token |
Used to obtain new tokens (expires in 365 days) |
expires_in |
Access token lifetime in seconds (86400 = 1 day) |
token_type |
Always "Bearer" |
Error Response
Error Response Format:
Error Types:
| Error | Description |
|---|---|
invalid_request |
Missing required parameter (e.g., grant_type) |
invalid_client |
Client authentication failed |
invalid_scope |
Invalid scope requested |
invalid_grant |
Authorization code expired or already used |
Token Management
Access tokens expire after 24 hours and must be refreshed using the refresh token. The refresh token itself expires 1 year after the initial login.
Token Refresh Process
When an access token expires, use the refresh token to obtain a new access token:
Example Request:
Recommended Practices
- Expiry Tracking: Calculate and store expiry timestamp for both access and refresh tokens
- Proactive Refresh: Refresh access tokens before expiry (recommended 1 hour before)
- User Re-authentication: Monitor refresh token expiry and prompt users to re-authenticate before the 1-year limit to prevent API access interruption
Important
When the refresh token nears expiration (recommended 30 days before), prompt users to re-authenticate through the login flow to maintain uninterrupted API access.
Quick Start Checklist
Before You Begin
- Contact BD representative for client ID
- Prepare HTTPS callback URL
Implementation Steps
- Redirect user to login page
- Handle callback with authorization code
- Exchange code for tokens
- Store tokens securely
- Make first API call
- Implement token refresh logic
Testing Your Integration
- Authentication Flow: Verify login redirect works
- Token Exchange: Confirm you receive valid tokens
- API Calls: Test with minimal scopes first
- Token Refresh: Verify refresh mechanism works
Troubleshooting
Common Issues
"Invalid redirect_uri"
Cause: Callback URL mismatch Solution: Ensure the redirect_uri exactly matches the URL registered with iglooworks
"403 Forbidden" on API calls
Cause: Insufficient scopes Solution: Check that your access token includes the required scope for the API endpoint
"Token expired" errors
Cause: Access token expired (24-hour limit) Solution: Implement automatic token refresh using the refresh_token
Getting Help
- Technical Issues: Contact your BD representative
- Integration Support: Email dev+support@igloohome.com