App Installation Flow
This guide explains how to implement the OAuth 2.0 app installation flow for client applications that will be listed in the ResDiary App Marketplace. When venues discover and install your app from the
Overview
The app installation flow enables venues to securely connect your application to their ResDiary diary. This flow combines:
App Marketplace Discovery: Venues browse and select your app
Install URL Redirect: ResDiary redirects to your app's install endpoint
OAuth 2.0 Authorization: Your app initiates the authorization code flow with PKCE
Access Token Exchange: Your app obtains tokens to access the venue's data
Prerequisites
Before implementing the app installation flow, ensure you have:
Created an App in the Developer Hub
Configured Install URL in your app settings
Configured Redirect URL for OAuth callbacks
Understanding of OAuth 2.0 authorization code flow with PKCE (see OAuth 2.0 Authorization Code Flow w/ PKCE)
Installation Flow Diagram

Step-by-Step Implementation
Step 1: Configure Install URL
In your app settings, configure the Install URL where venues will be redirected when they install your app from the marketplace.
Example Install URL:
💡 Tip: The Install URL should be a dedicated endpoint in your application that handles the installation flow. This endpoint will receive the
authorization_uriquery parameter from ResDiary.
Step 2: Receive Installation Request
When a venue clicks "Install" on your app in the marketplace, ResDiary redirects them to your Install URL with an authorization_uri query parameter.
Example redirect to your Install URL:
The authorization_uri parameter contains a partial URL to the OAuth authorization server with some pre-filled parameters:
Pre-filled parameters in authorization_uri:
client_id: Your application's Client IDscope: The API scope based on your app type (consumer_api,data_extract_api, orepos_api)microsite_name: The unique microsite name of the venue's diary being authorizedresponse_type: Set tocodefor authorization code flowredirect_uri: Your app's configured Redirect URL
Example authorization_uri value:
Step 3: Generate PKCE Parameters
Your install endpoint must generate PKCE (Proof Key for Code Exchange) parameters to secure the authorization flow.
Required PKCE parameters:
code_verifier: A cryptographically random string (43-128 characters)code_challenge: SHA-256 hash of the code_verifier, Base64 URL-encodedstate: A random string for CSRF protection
💡 Implementation Details: For detailed information on generating PKCE parameters with code examples in multiple languages, see Phase 1: Preparation
⚠️ Security Warning: Store the
code_verifierandstatesecurely in your session. You will need thecode_verifierto exchange the authorization code for an access token, and thestateto validate the callback.
Step 4: Complete Authorization URI
Add the missing PKCE parameters to the authorization_uri received from ResDiary:
Parameters to add:
code_challenge: The SHA-256 hashed code_verifier (Base64 URL-encoded)code_challenge_method: Must beS256state: Random string for CSRF protection
Example code to complete the authorization URI:
Complete authorization URI example:
Step 5: Redirect to Authorization Server
Redirect the venue user to the complete authorization URI to initiate the OAuth 2.0 authorization code flow.
Example redirect:
Step 6: Handle Authorization Callback
After the user authenticates and grants permissions, the OAuth authorization server redirects them back to your configured Redirect URL with an authorization code.
Example callback:
Callback parameters:
code: The authorization code to exchange for an access tokenstate: The state parameter you sent (must be validated)
Example callback handler:
✅ Best Practice: Always validate the
stateparameter to prevent CSRF attacks. The state value returned must exactly match the value you sent in the authorization request.
Step 7: Exchange Authorization Code for Access Token
Exchange the authorization code for an access token by making a POST request to the OAuth token endpoint with the authorization code and code verifier.
💡 Implementation Details: For complete information on token exchange including request format, parameters, response structure, and code examples, see Phase 3: Token Exchange
📖 Token Management: For information about token refresh and long-term access, see Phase 4: Token Management
Step 8: Store Tokens Securely
Store the access token and refresh token securely in your application's database or secure storage.
Security best practices:
Encrypt tokens at rest
Never store tokens in browser localStorage or sessionStorage
Associate tokens with the specific venue (microsite_name)
Store token expiry time for proactive refresh
Use secure HTTP-only cookies for web applications
Example token storage:
Complete Installation Flow Example
Here's a complete example of an install endpoint implementation:
Security Considerations
⚠️ Critical: All OAuth 2.0 flows MUST use HTTPS for all URLs (Install URL, Redirect URL, and API endpoints). Never use HTTP in production.
Installation-specific security requirements:
Always validate the
stateparameter in your callback to prevent CSRF attacksStore the
code_verifiersecurely in server-side session storageNever expose your
client_secretin client-side code or public repositoriesEncrypt tokens at rest in your database
Associate tokens with specific venues (microsite_name)
📖 Complete Security Guide: For comprehensive security best practices including HTTPS requirements, CSRF protection, client secret handling, token storage, and additional security recommendations, see Security Best Practices
Error Handling
Common Installation Errors
Missing authorization_uri
ResDiary didn't provide the parameter
Verify Install URL is correctly configured in app settings
Invalid authorization_uri
Malformed or incomplete URI
Validate URI format and required parameters
State mismatch
CSRF attack or session loss
Regenerate state and restart flow
Invalid authorization code
Code expired or already used
Authorization codes are single-use and expire quickly (typically 10 minutes)
Token exchange failed
Invalid credentials or parameters
Verify client_id, client_secret, and code_verifier are correct
📖 Complete Error Reference: For comprehensive error codes, troubleshooting guides, and solutions for authorization errors, token exchange errors, and refresh token errors, see Error Handling
Handling Installation Failures
Provide clear error messages and recovery options:
Testing the Installation Flow
Test Environment
Before submitting your app for production approval, test the installation flow in the Test Environment:
Configure your Install URL in the Test Environment settings
Use test credentials (Test Client ID and Client Secret)
Test with a test diary (microsite_name)
Verify token exchange and storage
Test API calls with obtained access tokens
Testing Checklist
Next Steps
After implementing the app installation flow:
Test thoroughly in the Test Environment
Submit your app for production approval
Implement token refresh to maintain long-term access (see Phase 4: Token Management)
Monitor installations and handle errors gracefully
Provide support for venues during installation
Summary
The OAuth 2.0 app installation flow enables venues to securely connect your application to their ResDiary diary:
Configure Install URL in your app settings
Receive installation request with
authorization_uriparameterGenerate PKCE parameters for secure authorization
Complete authorization URI with PKCE parameters
Redirect to authorization server for user authentication
Handle callback with authorization code
Exchange code for tokens using code_verifier
Store tokens securely for API access
By following this guide, you'll provide a seamless and secure installation experience for venues using your application.
Last updated
Was this helpful?
