Skip to main content
This guide builds the Quickstart flow into a Rails app with the BundleUp Ruby SDK. A user clicks Connect GitHub, authorizes on GitHub, and lands back in your app, which exchanges the one-time 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/callback registered under Auth → Redirect URIs,
    • an API key, and your Client ID from the Auth page.

Step 1: Create a new Rails app

Create a fresh Rails project:
This scaffolds a Rails app you can run locally.

Step 2: Install the BundleUp Ruby SDK

Add the bundleup-sdk gem to your Gemfile:
Then install dependencies:
This makes the BundleUp client available to your Rails app.

Step 3: Configure environment variables

Create a .env file (or use your preferred secrets manager) with:
.env
Make sure your Rails app loads these variables (for example via dotenv-rails or Rails credentials).

Step 4: Add routes

In config/routes.rb, define the home and callback endpoints:
config/routes.rb
In app/controllers/home_controller.rb, add:
app/controllers/home_controller.rb
Then create a simple view.
app/views/home/index.html.erb
This link sends the user to BundleUp’s auth server to authorize the integration.

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.
Then create app/views/home/callback.html.erb:
app/views/home/callback.html.erb
Now, after a successful authorization redirect, you exchange the code for a connection_id and use it to fetch a Unified API resource with the Ruby SDK.

Step 7: Run your application

Start the Rails server:
Visit http://localhost:3000, click Connect GitHub, authorize the app, and then you’ll see data fetched through BundleUp.

Next steps

  • Store the connection_id against the signed-in user in your database, and reuse it. Don’t send the user through the flow again.
  • Pass a state value 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.