code for a connection_id and lists their repositories through the Unified API.
Prerequisites
- Ruby 2.7+ and Rails installed.
- In the BundleUp dashboard, complete steps 1 to 3 of the Quickstart:
- a GitHub integration with the identifier
github, http://localhost:3000/callbackregistered under Auth → Redirect URIs,- an API key, and your Client ID from the Auth page.
- a GitHub integration with the identifier
Step 1: Create a new Rails app
Create a fresh Rails project:Step 2: Install the BundleUp Ruby SDK
Add thebundleup-sdk gem to your Gemfile:
Step 3: Configure environment variables
Create a.env file (or use your preferred secrets manager) with:
.env
Step 4: Add routes
Inconfig/routes.rb, define the home and callback endpoints:
config/routes.rb
Step 5: Create the authorization link
Inapp/controllers/home_controller.rb, add:
app/controllers/home_controller.rb
app/views/home/index.html.erb
Step 6: Handle the callback and fetch data
After authorization, BundleUp redirects back to/callback with a one-time code. Your server exchanges it, using your API key, for a connection_id. The code expires after 5 minutes and can only be used once.
Add a callback action to HomeController:
app/controllers/home_controller.rb
redirect_uri must be exactly the same value you used to start the flow. BundleUp rejects the exchange otherwise.app/views/home/callback.html.erb:
app/views/home/callback.html.erb
connection_id and use it to fetch a Unified API resource with the Ruby SDK.
Step 7: Run your application
Start the Rails server:Next steps
- Store the
connection_idagainst the signed-in user in your database, and reuse it. Don’t send the user through the flow again. - Pass a
statevalue when you build the authorization URL and check it in the callback, to protect against CSRF. See Connecting user accounts. - Pass an
external_id(your user ID) so you can find connections by user later. - Call the provider directly through the Proxy when you need something the Unified API doesn’t cover.
- See the full Ruby SDK reference.

