Sha256: 8b6658e97b0d4f35d2a51501a583ad5dfcf7607e223f2d760ef457bc195dbb93

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require 'omniauth-oauth'
require 'nokogiri'

module OmniAuth
  module Strategies
    class GetGlue < OmniAuth::Strategies::OAuth
      option :client_options, {
        :site               => 'http://api.getglue.com',
        :authorize_url      => 'http://getglue.com/oauth/authorize',
        :request_token_url  => 'https://api.getglue.com/oauth/request_token',
        :access_token_url   => 'https://api.getglue.com/oauth/access_token'
      }

      uid { username }

      info do
        {
          'uid'   => username,
          'name'  => display_name
        }
      end

      extra do
        { 'raw_info' => 'raw_info' }
      end

      def username
        raw_info.xpath("/adaptiveblue/response/profile/username").inner_text
      end

      def display_name
        raw_info.xpath("/adaptiveblue/response/profile/displayName").inner_text
      end

      def raw_info
        @raw_info ||= Nokogiri::XML(access_token.get('http://api.getglue.com/v2/user/profile').body)
      end
    end
  end
end

OmniAuth.config.add_camelization 'getglue', 'GetGlue'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-getglue-0.1.0 lib/omniauth/strategies/getglue.rb