Skip to content

Latest commit

 

History

History
66 lines (52 loc) · 1.7 KB

README.md

File metadata and controls

66 lines (52 loc) · 1.7 KB

OmniAuth Hubspot

Hubspot OAuth2 Strategy for OmniAuth.

Read the Hubspot OAuth docs for more details:

Installing

Add to your Gemfile:

gem 'omniauth-hubspot', '~> 0.1.0', github: 'advocately/omniauth-hubspot'

Then bundle install.

Usage

OmniAuth::Strategies::Hubspot is simply a Rack middleware. Read the OmniAuth docs for detailed instructions: https://github.com/intridea/omniauth.

Here's a quick example, adding the middleware to a Rails app in config/initializers/omniauth.rb:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :hubspot, ENV['HUBSPOT_KEY'], ENV['HUBSPOT_SECRET']
end

To start the authentication process with Hubspot you simply need to access /auth/hubspot route.

Auth Hash

Here's an example Auth Hash available in request.env['omniauth.auth']:

{
  :provider => 'hubspot',
  :uid => '342324',
  :info => {
    :email => '[email protected]',
    :name => 'Kevin Antoine'
  },
  :credentials => {
    :token => 'dG9rOmNdrWt0ZjtgzzE0MDdfNGM5YVe4MzsmXzFmOGd2MDhiMfJmYTrxOtA=', # OAuth 2.0 access_token, which you may wish to store
    :expires => false
  },
  :extra => {
    :raw_info => {
      :name => 'Kevin Antoine',
      :email => '[email protected]',
      :type => 'admin',
      :id => '342324',
      :app => {
        :id_code => 'abc123', # Company app_id
        :type => 'app',
        :secure => true # Secure mode enabled for this app
  :timezone => "Dublin",
  :name => "ProjectMap"
      },
      :avatar => {
        :image_url => "https://static.hubspotassets.com/avatars/343616/square_128/me.jpg?1454165491"
      }
    }
  }
}