A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Gusto/omniauth-gusto below:

Gusto/omniauth-gusto: OmniAuth strategy for Gusto

Official OmniAuth strategy for authenticating to use Gusto’s API with OAuth 2.

Add this line to your application's Gemfile:

And then execute:

Or install it yourself as:

$ gem install omniauth-gusto

Integrate the strategy into your middleware. Refer to Devise’s documentation if using Devise.

# config/initializers/omniauth.rb

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :gusto, ENV['GUSTO_CLIENT_ID'], ENV['GUSTO_CLIENT_SECRET']
end

The route /auth/gusto will become available to initiate authentication. Set up the callback route /auth/gusto/callback and tie to a controller action to handle any post-authentication actions.

# config/routes.rb

Rails.application.routes.draw do
  get '/auth/gusto/callback', to: 'sample_controller#gusto'
end

For more information on how to use OmniAuth, refer to the OmniAuth documentation.

Use the access token from the Auth Hash request.env['omniauth.auth']['credentials']['token'] to make calls to other Gusto API endpoints such as payrolls. To gain access to Gusto’s API, contact Gusto to establish a client id and secret.

Below is an example Auth Hash availble in request.env['omniauth.auth']. Note info['name'] is set to the user’s email and that employee names will have to be fetched from the employees endpoint.

{
  "provider" => "gusto",
  "uid" => 123,
  "info" => {
    "email" => "example.user@gmail.com",
    "name" => "example.user@gmail.com"
  },
  "credentials" => {
    "token" => "456",
    "refresh_token" => "789",
    "expires_at" => 1561589955,
    "expires" => true
  },
  "extra" => {
    "raw_info" => {
      "id" => 123,
      "email" => "example.user@gmail.com",
      "roles" => {
        "payroll_admin" => {
          "companies" => [
            {
              "id" => 101112,
              "name" => "Poi's Doughnuts",
              "trade_name" => null,
              "locations" => [
                {
                  "id" => 131415,
                  "street_1" => "1236 Mission St",
                  "street_2" => "",
                  "city" => "San Francisco",
                  "state" => "CA",
                  "zip" => "94103",
                  "country" => "USA",
                  "active" => true
                }
              ]
            }
          ]
        }
      }
    }
  }
}

The gem is available as open source under the terms of the MIT License.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4