Sha256: d4c2a595153e26be7b2165d146204f1bdb67c0dd0d9ded3b96f0888465bb64e3

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require 'omniauth/strategies/oauth2'

module OmniAuth
  module Strategies
    class Teamwork < OmniAuth::Strategies::OAuth2
      option :name, 'teamwork'

      option :client_options, {
        site: 'https://www.teamwork.com/',
        authorize_url: 'https://www.teamwork.com/launchpad/login',
        token_url: 'https://www.teamwork.com/launchpad/v1/token'
      }

      uid { raw_info['id'] }

      info do
        {
          email: raw_info['email_address'],
          first_name: raw_info['first_name'],
          last_name: raw_info['last_name'],
          avatar_url: raw_info['avatar_url']
        }
      end

      credentials { { token: access_token.token } }

      extra { { raw_info: raw_info } }

      def callback_url
        options[:redirect_uri] || (full_host + script_name + callback_path)
      end

      def raw_info
        url = "#{access_token.response.parsed.installation.api_end_point}me.json"
        @raw_info ||= access_token.get(url).parsed.person
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
omniauth-teamwork-1.0.1 lib/omniauth/strategies/teamwork.rb
omniauth-teamwork-1.0.0 lib/omniauth/strategies/teamwork.rb