Sha256: 84e05ac7c8d0ef1d78f4396b25f065ea83fb484ad4d49e62fde6bedbb76f7e91

Contents?: true

Size: 787 Bytes

Versions: 1

Compression:

Stored size: 787 Bytes

Contents

# frozen_string_literal: true

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class Timetree < OmniAuth::Strategies::OAuth2
      option :name, 'timetree'
      option :client_options, site: 'https://timetreeapp.com',
                              authorize_url: '/oauth/authorize',
                              token_url: '/oauth/token'

      uid { raw_info[:id] }

      extra do
        { raw_info: raw_info }
      end

      def raw_info
        endpoint = 'https://timetreeapis.com/user'
        options = { headers: { 'Accept' => 'application/vnd.timetree.v1+json' } }
        @raw_info ||= access_token.get(endpoint, options).parsed['data'] || {}
      end

      def callback_url
        full_host + script_name + callback_path
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-timetree-0.1.1 lib/omniauth/strategies/timetree.rb