You'll use the <ahref="https://github.com/OmniAuth/OmniAuth"target="\_blank">OmniAuth</a> plugin to setup Blockstack authentication. OmniAuth is a popular framework for integrating third-party authentication with a ruby on rails website. Blockstack provides an OmniAuth plugin, <ahref="https://github.com/blockstack/OmniAuth-blockstack"target="\_blank">OmniAuth-blockstack</a> to make this easy for you.
2. Edit the `Gemfile` in the root of your project and add two gems, one for OmniAuth and one for the Blockstack plugin.
```ruby
gem 'omniauth'
gem 'omniauth-blockstack'
```
3. Save and close the `Gemfile`.
4. Install the gems by running the `bundle install` command.
```bash
$ bundle install
```
{% include note.html content="<p>If the <code>bundle</code> command returns a message:</p>
<p><code>Your Ruby version is 2.0.0, but your Gemfile specified 2.5.1</code></p>
<p>Check if the auto-generated <code>Gemfile</code> includes a line that specifies a conflicting Ruby version. Make sure your `ruby` version matches the <code>Gemfile</code> by running <code>ruby -v</code> You can either switch to that version, or remove the line <code>ruby '2.5.1'</code> from your <code>Gemfile</code></p>."%}
## Add a OmniAuth callback for Blockstack
1. Create a new file at `config/initializers/omniauth.rb`.
```bash
$ touch config/initializers/omniauth.rb
```
You'll use this file to configure the OmniAuth gem and the Blockstack plugin.
2. Edit your new `config/initializers/omniauth.rb` file and add the following code:
```ruby
Rails.application.config.middleware.use OmniAuth::Builder do
provider :blockstack
end
```
This adds the OmniAuth middleware to your project, and tells OmniAuth
to use the Blockstack provider. After a user signs in with OmniAuth, you need
to specify a `callback` method for Blockstack to handle the rest of the sign in flow.
The callback method is typically where you grab the authentication information from the
third party, save some data, and sign the user in to your application by
saving information in cookies.
3. Save and close the `config/initializers/omniauth.rb` file.
3. Edit the `/app/controllers/pages_controller.rb` file
This file defines a `PagesController` class where you will add the
`blockstack_callback` method. When you are done the file should look like
Let folks know your work by tweeting: <ahref="https://twitter.com/share?ref_src=twsrc%5Etfw"class="twitter-share-button"data-size="large"data-text="I just built a sample decentralized application with Blockstack! "data-hashtags="blockstack, blockchain"data-show-count="false">Tweet your work!</a><scriptasyncsrc="https://platform.twitter.com/widgets.js"charset="utf-8"></script>