Sha256: f03b1fb30564d04db93918bba2ab514f41f47003dcf627fe0114354e8c47701b

Contents?: true

Size: 910 Bytes

Versions: 2

Compression:

Stored size: 910 Bytes

Contents

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class Flattr < OmniAuth::Strategies::OAuth2

      option :client_options, {
        :site          => "https://api.flattr.com",
        :authorize_url => "https://flattr.com/oauth/authorize",
        :token_url     => "https://flattr.com/oauth/token"
      }

      def request_phase
        super
      end

      uid { raw_info['username'] }

      info do
        {
          'nickname' => raw_info['username'],
          'name' => raw_info['firstname'] + raw_info['lastname'],
          'image' => raw_info['avatar'],
          'urls' => {
            'Flattr' => raw_info['link'],
          },
        }
      end

      extra do
        {:raw_info => raw_info}
      end

      def raw_info
        @raw_info ||= access_token.get("/rest/v2/user").parsed
      end

    end
  end
end

OmniAuth.config.add_camelization "flattr", "Flattr"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
omniauth-flattr-0.1.1 lib/omniauth/strategies/flattr.rb
omniauth-flattr-0.1.0 lib/omniauth/strategies/flattr.rb