Sha256: 82387bca377f4c629906b30939c01da6cdc54b0abcec365abd88b737f7548f59
Contents?: true
Size: 1.64 KB
Versions: 2
Compression:
Stored size: 1.64 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, { :locale => "kg", :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 initialize app, *args, &block super raise ArgumentError.new("Available locales are only kg or net") if options.locale && !%w(kg net).include?(options.locale) options.client_options.site = "http://api.namba.#{options.locale || 'kg'}" options.client_options.authorize_url = "http://login.namba.#{options.locale || 'kg'}/login2.php" end def raw_info @raw_info ||= MultiJson.load(access_token.get("http://api.namba.#{options.locale || 'kg'}/getUserInfo2.php").body) rescue ::Errno::ETIMEDOUT raise ::Timeout::Error end end end end OmniAuth.config.add_camelization 'namba', 'Namba'
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
omniauth-namba-1.0.1 | lib/omniauth/strategies/namba.rb |
omniauth-namba-1.0.0 | lib/omniauth/strategies/namba.rb |