Sha256: 3b25a0b5aa3c6481d6213f8e0e1a9fe2771f741c29ab0e90584fdc28e79435d0

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require 'omniauth-oauth'
require 'multi_json'
require 'net/http'

module OmniAuth
  module Strategies
    class Namba < OmniAuth::Strategies::OAuth

      option :name, "namba"
      option :client_options, {
        :site => "http://api.namba.kg",
        :request_token_path => "/oauth/request_token.php", 
        :authorize_url => "http://login.namba.kg/login2.php",
        :access_token_path => "/oauth/access_token.php"
      }

      option :fields, ["status", "login", "firstname", "lastname", "birthdate", "sex", "avatar"]

      uid { raw_info['login'] }

      info do
        {
          :status => raw_info['status'],
          :login => raw_info['login'],
          :firstname => raw_info['firstname'],
          :lastname => raw_info['lastname'],
          :birthdate => raw_info['birthdate'],
          :sex => raw_info['sex'],
          :avatar => raw_info['avatar']
        }
      end

      extra do
        {
          'raw_info' => raw_info
        }
      end

      def raw_info
        @raw_info ||= MultiJson.load(access_token.get('http://api.namba.kg/getUserInfo2.php').body)
      rescue ::Errno::ETIMEDOUT
        raise ::Timeout::Error
      end

    end
  end
end

OmniAuth.config.add_camelization 'namba', 'Namba'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-namba-0.0.1 lib/omniauth/strategies/namba.rb