<repo_name>felixclack/omniauth-dropbox<file_sep>/lib/omniauth-dropbox.rb
require 'omniauth/strategies/dropbox'

<file_sep>/lib/omniauth/strategies/dropbox.rb
require 'omniauth-oauth2'
require 'json'

module OmniAuth
  module Strategies
    class Dropbox < OmniAuth::Strategies::OAuth2
      option :name, 'dropbox'
      option :client_options, {
        site: 'https://api.dropbox.com',
        authorize_url: 'https://www.dropbox.com/1/oauth2/authorize',
        token_url: 'https://api.dropbox.com/1/oauth2/token'
      }

      uid { raw_info['uid'].to_s }

      info do
        {
          uid: raw_info['uid'],
          name: raw_info['display_name'],
          email: raw_info['email']
        }
      end

      extra do
        { raw_info: raw_info }
      end

      def raw_info
        @raw_info ||= JSON.parse(access_token.get('/1/account/info').body)
      end
    end
  end
end

<file_sep>/Gemfile
source 'https://rubygems.org'

gemspec
# Specify your gem's dependencies in omniauth-eindx.gemspec
group :test do
  gem 'rack-test'
  gem 'rake'
  gem 'rspec'
  gem 'webmock'
end

<file_sep>/README.md
# Omniauth::Dropbox

An OmniAuth strategy for connecting to Dropbox.

Add this to `config/initializers/devise.rb`

    Devise.setup do |config|
      ...
      config.omniauth :dropbox, APP_ID, APP_SECRET
    end

