Ruby on Rails quickstart
Add Wocha authentication to a Rails application with OmniAuth OIDC for browser login and JWT validation for API mode, plus the Management API for admin tasks.
Add Wocha authentication to a Rails application: OmniAuth OIDC for browser login and JWT validation for API mode, plus the Management API for admin tasks.
Prerequisites
- Ruby 3.2+
- Rails 7.1+
- A Wocha project with OAuth applications (Wocha Console)
- Confidential client for server-side web login; public or confidential for API token validation
What you'll build
A Rails app with OmniAuth browser login, JWT API validation, and Management API integration.
Welcome back
After sign-in
✓ Session stored securely
✓ User profile available in your app
✓ Organisation context ready for multi-tenant features
Installation
Environment variables
Register redirect URI: http://localhost:3000/auth/wocha/callback
OmniAuth OIDC strategy
Create config/initializers/omniauth.rb:
Add routes in config/routes.rb:
Create app/controllers/sessions_controller.rb:
Protect controllers with a before_action:
JWT validation for API mode
Create app/services/greet_jwt_validator.rb:
Create app/controllers/concerns/authenticates_api.rb:
Use in an API controller:
Management API
Create app/services/greet_management_client.rb:
Testing the integration
Web login
- Start Rails:
bin/rails server - Visit http://localhost:3000/login
- Complete login on the hosted Wocha UI
- Confirm you reach
/dashboardwith a session
API mode
Next steps
- SDK reference — hooks, server helpers, and configuration options
- Webhooks overview — receive user and session lifecycle events
- Common patterns — protect routes, org switching, and role-based UI